asp.net-mvc-routing

How do I set the default namespaces in MapHttpRoute?

拟墨画扇 提交于 2020-01-10 07:52:06
问题 With the standard MapRoute method a can pass a string collection representing the namespaces in which to search for my controller. This seems to have disappeared from MapHttpRoute. How does one define the default namespaces using the new API routing? 回答1: We had this problem with the Umbraco core so we created our own IHttpControllerSelector, the source code can be found here: https://github.com/WebApiContrib/WebAPIContrib/blob/master/src/WebApiContrib/Selectors

Default dynamic + static route in asp.net MVC 5

杀马特。学长 韩版系。学妹 提交于 2020-01-06 14:41:31
问题 When I run my application I get following URL in address bar. http://Localhost/ application default Routing, routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Login", action = "Login", id = UrlParameter.Optional } ); But what I want to set is, When I run my application I want to see URL like this, http://localhost/clientName/login (I want to display this fixed URL on start up of application) Lets say at this moment user is shown with Login

MVC routing doesn't pickup querystring

大憨熊 提交于 2020-01-06 08:21:12
问题 in my Global.ascx.cs, I have this setting for the routing: routes.MapRoute( "HomeTarget", "{TargetCode}", new { controller = "Home", action = "Index", TargetCode = "" }); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults In my HomeController, I have an Index() action like this: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Index(string TargetCode) { return View(); }

Giving route or Migrating ASP.net Web Form to ASP.net MVC?

冷暖自知 提交于 2020-01-06 04:46:29
问题 I have a full web form application and want to migrate to MVC, before starting that I have been trying to implement The club site http://www.asp.net/downloads/starter-kits/extended-club using the instruction of Rob Conery, Scott Hanselman, Phil Haack in the book of Professional ASP.net MVC 2 in Chapter 12 . http://media.wiley.com/assets/1539/15/professionalaspnet35mvc_chapter13.pdf I've created a folder for web form site, modified the Site.Master in shared folder using the web form master

How to force a single domain to be used for ASP.NET MVC site?

混江龙づ霸主 提交于 2020-01-06 04:07:41
问题 I currently have an ASP .NET MVC site that has two domains pointing to it (e.g. www.domainA.com and www.domainB.com). I would like to change all of my links to use www.domainA.com even if www.domainB.com is visited. All of my urls are generated by the built-in Url.Action and Html.ActionLink methods. I followed the instructions in a previous question but I can't quite get it working. Here is my custom route : public class MultipleDomainRoute : System.Web.Routing.Route { public

How to force a single domain to be used for ASP.NET MVC site?

戏子无情 提交于 2020-01-06 04:07:29
问题 I currently have an ASP .NET MVC site that has two domains pointing to it (e.g. www.domainA.com and www.domainB.com). I would like to change all of my links to use www.domainA.com even if www.domainB.com is visited. All of my urls are generated by the built-in Url.Action and Html.ActionLink methods. I followed the instructions in a previous question but I can't quite get it working. Here is my custom route : public class MultipleDomainRoute : System.Web.Routing.Route { public

How to route all IIS requests to my MVC app?

家住魔仙堡 提交于 2020-01-06 02:33:18
问题 I'm creating an MVC 3 app that manages business for client companies. When deployed, incoming requests should prominently feature the name of the client company; thus, http://hosteddomain.com/Excelsior/Home/Dashboard/3 should retrieve the home page for a user from client Excelsior. Question 1 : On the development server this works fine ( localhost:28497/ClientCompany/... ) because my RouteConstraint looks up the business name. However, when I deploy this, how do I tell IIS to send all

Input URL like http://example.com changes to http:/example.com in action input

混江龙づ霸主 提交于 2020-01-05 07:10:02
问题 I asked a question to get URL as action input here. Now I have a new problem. The passed URL to action changes from http://example.com to http:/example.com . I want to know why and how can I resolve the problem. P.S: I added this code to resolve but I think there may be another problems in future! the code is: if ((url.Contains(":/")) && !(url.Contains("://"))) { url = url.Replace(":/", "://"); } 回答1: The browser (or server) is replacing a double slash (illegal) with a single one. Try it,

Create Custom 301 Redirect Page

左心房为你撑大大i 提交于 2020-01-05 04:50:49
问题 I am attempting to write a 301 redirect scheme using a custom route (class that derives from RouteBase) similar to Handling legacy url's for any level in MVC. I was peeking into the HttpResponse class at the RedirectPermanent() method using reflector and noticed that the code both sets the status and outputs a simple HTML page. this.StatusCode = permanent ? 0x12d : 0x12e; this.RedirectLocation = url; if (UriUtil.IsSafeScheme(url)) { url = HttpUtility.HtmlAttributeEncode(url); } else { url =

How to deal with IIS sub applications using MVC routing?

为君一笑 提交于 2020-01-05 03:28:41
问题 I have an MVC application that has been moved to a sub folder in the wwwroot, and this sub folder has been made an application via IIS. So whereas before the url to my login page would look like this: www.mydomain.com/login It now looks like this: www.mydomain.com/application/login The application works fine, it doesn't seem to have affected the routing or any of the links in my application. However, it is causing problems where I am referencing image src's like so: <img src="/content/images