Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Andy Hochstetler

@Andy Hochstetler
About
Posts
4
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Write Binary Files to the Browser
    A Andy Hochstetler

    Here's code from a production app that has been running for nearly a year that serves PDFs. We noticed some problems with IE 5.5 without the latest service packs. However, no server-side problems. Document CurrentDoc = Document.Find(currentArea, currentUser, DocumentID); string TempFilePath = ConfigurationSettings.AppSettings["TempDir"] + "/" + SessionID + "/" + CurrentDoc.FileName; if (Method == "View") { LogEntry.Save(currentUser, CurrentDoc, LogEntry.AccessTypeEnum.View, DateTime.Now); Response.AddHeader("Content-Disposition", "inline;filename=" + CurrentDoc.FileName); } else { LogEntry.Save(currentUser, CurrentDoc, LogEntry.AccessTypeEnum.Download, DateTime.Now); Response.AddHeader("Content-Disposition", "attachment;filename=" + CurrentDoc.FileName); } // Serve it CurrentDoc.SaveDocContentsToFile(TempFilePath); Response.AddHeader("Content-Length", CurrentDoc.FileSize.ToString()); Response.ContentType = CurrentDoc.ContentType; Response.WriteFile(TempFilePath); Response.End(); Andy Hochstetler

    ASP.NET question

  • Write Binary Files to the Browser
    A Andy Hochstetler

    RT1970 wrote: I tried to write binary files to the browser based on the codes found in Microsoft Knowledge Base Article 306654: //Set the appropriate ContentType. Response.ContentType = "Application/pdf"; //Get the physical path to the file. string FilePath = MapPath("acrobat.pdf"); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); Response.End(); The codes works for many kinds of file types, like DOC, PPT, XLS... but not for PDF. When it's a PDF file, Response.End will throw a ThreadAbortException because "the current response ends prematurely". I also tried BinaryWrite, Flush, no difference. Anyone has any suggestion?

    Have you tried setting the ContentLength? I had a similar problem with PDFs and setting this property to the actual file size cured the problem for me.

    Andy Hochstetler

    ASP.NET question

  • Coding Style
    A Andy Hochstetler

    Paul Watson wrote: To be honest I have variable naming diarrhea. e.g. a TextBox for a first name is textboxFirstName. I do trim it though if the class name is too long (like SqlDataReader).

    I've followed the Microsoft documentation where I append my data type to the end. Usually, it's something like this: FirstNameTextBox, YesNoCheckBox or maybe MyCustomException. That's for local variables. For instance variables and parameter values, I use the camel casing, so I might have a variable called sampleTextBox. Using the different casing helps me to identify scope. Andy Hochstetler

    The Lounge csharp question c++ wpf com

  • Problems with Exception Management Application Block
    A Andy Hochstetler

    I'm having difficulty getting the Microsoft Application Block for Exception Management working. In particular, I'm trying to customize the DefaultPublisher so that it uses a custom log source in the EventLog. Here are some of my constraints, many of which I've overcome. 1) I wanted the assembly deployed to the GAC so that more than one app could share it. 2) My apps are web apps, so I had to deal with security issues regarding getting a custom log source set up. OK, so I created my strong names for the ExceptionManagement and Interfaces assemblies, and got both installed to the GAC. No problem. I used the INSTALLUTIL.EXE to run the custom installer for the ExceptionManagement assembly. So far so good. I manually created the registry key and string value for my log source. Next, I set up the web.config file. Here's the way I had it set up the first time:

    Now when I generated an exception, several were logged using my custom log source, including several that it was unable to find the type for the section handler. Well, I figured out that it was because I had an assembly in the GAC and hadn't fully qualified the names. So I fixed the web.config to be:

    Well, now to the point I'm at now. I get an internal exception that has the following detail. I'm at wits end! Any help would greatly be appreciated!!! Thanks, Andy 1) Exception Information *****************************************

    .NET (Core and Framework) help dotnet windows-admin security
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups