Prevent IIS from serving static files through ASP.NET pipeline

I’m taking a guess here and suspect that you have the following setting configured in your web.config file: <modules runAllManagedModulesForAllRequests=”true”> This means that every request, including those for static content is hitting the pipeline. Change this setting to: <modules runAllManagedModulesForAllRequests=”false”> This is assuming your application is running under ASP.NET 4.0 and MVC3. For this to … Read more

Storing more information using FormsAuthentication.SetAuthCookie

You can add user data to the FormsAuthenticationTicket, then generate the cookie yourself. There’s an example in the the MSDN documentation for FormsAuthenticationTicket. EDIT Note that when creating the ticket, you need to set the timeout, which in general you will want to be the same as the value configured in web.config. Unfortunately, in the … Read more

How to allow an anonymous user access to some given page in MVC?

In MVC you normally use the [Authorize] attribute to manage authorization. Controllers or individual actions that are dressed with that attribute will require that the user is authorized in order to access them – all other actions will be available to anonymous users. In other words, a black-list approach, where actions that require authorization are … Read more