Implementing “Remember Me” Feature in ASP.NET MVC

First off, you should never store the user’s credentials in a cookie. It’s incredibly insecure. The password will be passed with every request as well as being stored in plain text on the user’s machine. Second, don’t reinvent the wheel, especially when security is concerned, you’ll never get it right. ASP.Net already provides this functionality … Read more

jQuery Mobile/MVC: Getting the browser URL to change with RedirectToAction

I think I’ve found an answer. Buried deep in the jQuery Mobile documentation, there is information about setting the data-url on the div with data-role=”page”. When I do this, I get the nice jQuery Mobile AJAX stuff (page loading message, page transitions) AND I get the url in the browser updated correctly. Essentially, this is … Read more

ASP.NET MVC – Routing – an action with file extension

You need to map requests for your XML files to TransferRequestHandler in web.config. Otherwise IIS will handle the request. Jon Galloway explains how to do this here. In summary, you add this element to location/system.webServer/handlers in your web.config: <add name=”XmlFileHandler” path=”*.xml” verb=”GET” type=”System.Web.Handlers.TransferRequestHandler” preCondition=”integratedMode,runtimeVersionv4.0″ />

ASP.net MVC4 WebApi route with file-name in it

You could add the following handler to the <handlers> section of your <system.webServer>: <add name=”ManagedDllExtension” path=”api/nav/*/*.dll” verb=”GET” type=”System.Web.Handlers.TransferRequestHandler” preCondition=”integratedMode,runtimeVersionv4.0″ /> This will make all requests containing .dll be served through the managed pipeline. Also notice how I have limited them only to the GET verb to limit the performance impact.

How do I route a URL with a querystring in ASP.NET MVC?

You cannot include the query string in the route. Try with a route like this: routes.MapRoute(“OpenCase”, “ABC/ABC{stepNo}”, new { controller = “ABC1”, action = “OpenCase” }); Then, on your controller add a method like this: public class ABC1 : Controller { public ActionResult OpenCase(string stepno, string key, string group) { // do stuff here return … Read more

How to change route to username after logged in?

You need to add a route to cover the case that has a user name. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapRoute( name: “Username_Default”, url: “{username}/{controller}/{action}/{id}”, defaults: new { controller = “Home”, action = “Index”, id = UrlParameter.Optional }, constraints: new { username = new OwinUsernameConstraint() } ); routes.MapRoute( name: “Default”, url: “{controller}/{action}/{id}”, defaults: … Read more

How do I configure ASP.NET MVC routing to hide the controller name on a “home” page?

Try this: private void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapRoute(“default”, “{controller}/{action}/{id}”, new { action = “index”, id = “” }, // Register below the name of all the other controllers new { controller = @”^(account|support)$” }); routes.MapRoute(“home”, “{action}”, new { controller = “device”, action = “index” }); } e.g. /foo If foo is not a controller … Read more