MVC 4 Remove “home” from base route

Try something like this: routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapRoute( “OnlyAction”, “{action}”, new { controller = “Home”, action = “Index” } ); routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}”, // URL with parameters new { controller = “Home”, action = “Index”, id = UrlParameter.Optional } // Parameter defaults );

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

ASP.NET MVC – how to get a full path to an action

You mean like using the Action method on the Url helper: <%= Url.Action(“DoThis”, “MyController”) %> or in Razor: @Url.Action(“DoThis”, “MyController”) which will give you a relative url (/MyController/DoThis). And if you wanted to get an absolute url (http://localhost:8385/MyController/DoThis): <%= Url.Action(“DoThis”, “MyController”, null, Request.Url.Scheme, null) %>

How can I create a friendly URL in ASP.NET MVC?

There are two steps to solve this problem. First, create a new route or change the default route to accept an additional parameter: routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}/{ignoreThisBit}”, new { controller = “Home”, action = “Index”, id = “”, ignoreThisBit = “”} // Parameter defaults ) Now you can type whatever you want to … Read more

How can I create a route constraint of type System.Guid?

Create a RouteConstraint like the following: public class GuidConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (values.ContainsKey(parameterName)) { string stringValue = values[parameterName] as string; if (!string.IsNullOrEmpty(stringValue)) { Guid guidValue; return Guid.TryParse(stringValue, out guidValue) && (guidValue != Guid.Empty); } } return false; }} Next when adding … Read more

How to access the current HttpRequestMessage object globally?

It’s not impossible as I have just recently found out. It’s actually added into the Items property of the current HttpContext (if there is one) =[ HttpRequestMessage httpRequestMessage = HttpContext.Current.Items[“MS_HttpRequestMessage”] as HttpRequestMessage Edit: This is as of WebAPI v2 .. I cannot be sure of previous versions.

How am I supposed to use ReturnUrl = ViewBag.ReturnUrl in MVC 4

When using forms authentication and the user is not authenticated or authorized the ASP.NET security pipeline will redirect to the login page and pass as a parameter in the query string the returnUrl equal to the page that redirected to the login page. The login action grabs the value of this parameter and puts it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)