Session timeout in ASP.NET

Are you using Forms authentication? Forms authentication uses it own value for timeout (30 min. by default). A forms authentication timeout will send the user to the login page with the session still active. This may look like the behavior your app gives when session times out making it easy to confuse one with the … Read more

I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it

If your page does not modify any session variables, you can opt out of most of this lock. <% @Page EnableSessionState=”ReadOnly” %> If your page does not read any session variables, you can opt out of this lock entirely, for that page. <% @Page EnableSessionState=”False” %> If none of your pages use session variables, just … Read more

Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine

Sections don’t work in partial views and that’s by design. You may use some custom helpers to achieve similar behavior, but honestly it’s the view’s responsibility to include the necessary scripts, not the partial’s responsibility. I would recommend using the @scripts section of the main view to do that and not have the partials worry … Read more

Returning binary file from controller in ASP.NET Web API

Try using a simple HttpResponseMessage with its Content property set to a StreamContent: // using System.IO; // using System.Net.Http; // using System.Net.Http.Headers; public HttpResponseMessage Post(string version, string environment, string filetype) { var path = @”C:\Temp\test.exe”; HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(path, FileMode.Open, FileAccess.Read); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue(“application/octet-stream”); … Read more