asp.net-mvc-routing

cannot set Default route for MVC project

前提是你 提交于 2019-12-13 19:46:31
问题 I cannot set the Default Route for my MVC project. When I run the project, it goes to the address http://localhost:7555/ and it give the "HTTP ERROR 404" but if I enter the url http://localhost:7555/Default , it goes to the Default page. But I want users to go the Default page even if they dont enter http://localhost:7555/Default. here is my Route in Global.asax routes.MapRoute( "Default", // Route name "{controller}/{action}/{Filtre}", // URL with parameters new { controller = "Default",

ASP.NET MVC Routing: Clean Urls - from camel case to hyphenated words

[亡魂溺海] 提交于 2019-12-13 19:33:27
问题 I currently have an action defined in my controller: // GET: /schools/:cleanUrlName/data-loggers public ActionResult DataLoggers(string cleanUrlName) { return View(); } This works when I hit "/schools/brisbane-state-high-school/dataloggers", however - as per the comment - I want to access it via a slightly cleaner url (using hyphens): "/schools/brisbane-state-high-school/data-loggers". I know I could write a route to accomplish this, but I was hoping I wouldn't have to write a new route for

How to avoid “/Home” in the url

前提是你 提交于 2019-12-13 18:28:45
问题 I am using the standard MVC template in VS 2013. With the default set up, http://website/ will be routed to website/Home/Index. How do I route all "actions" directly under website root url, eg http://website/xxx, to show the same content as http://website/Home/xxx? For example, how do I make http://website/About to execute the About action in the Home controller? If possible, the solution shouldn't be a Http redirect to http://website/Home/About because I don't want to show the "ugly" Home/

Getting MVC default route to go to ~/default.asp

冷暖自知 提交于 2019-12-13 15:54:47
问题 I am adding some MVC features to an existing site (FWIW, most of which is in classic ASP). As a result, I need to keep the default routing going to ~/default.asp (at a minimum - preferably the default document specified in IIS). Is there a way to write the route in RegisterRoutes so that a request for the root of the site (e.g., http://localhost, http://localhost/, or http://localhost/default.asp) will directly get the default page, and not attempt to find a controller/action? Or do I need to

MVC Ambiguous Action for Login

被刻印的时光 ゝ 提交于 2019-12-13 15:41:59
问题 I've got an ASP.NET MVC4 website (using vs2012) that allows users to login by clicking the "login" link. I'm getting the infamous error: The current request for action 'Login' on controller type 'AccountController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Login() on type MyProject.Controllers.AccountController System.Web.Mvc.ActionResult Login(MyProject.Clients) on type MyProject.Controllers.AccountController I've checked a bunch of links on here,

How to route web pages on a mixed MVC and Web Forms

ⅰ亾dé卋堺 提交于 2019-12-13 14:15:54
问题 I have created a mixed MVC and Web Forms web site - very easy to do with the later Visual Studio 2013 tooling. All works well and I can navigate to both MVC and Web Forms pages correctly. What I would like to do however, is to put all of my Web Form pages in a specific sub-directory and then route to them without using the sub-directory. / + Content + Controllers + Models + Scripts + Views + WebPages + Default.aspx + MyWebForm.aspx So I would like to be able to access: /WebPages/Default.aspx

MVC- How to get parameter value from get request which has parameter names including dot characters

↘锁芯ラ 提交于 2019-12-13 11:52:43
问题 In MVC, I know we can get parameters from a get request like this: Request: http://www.example.com/method?param1=good&param2=bad And in controller public ActionResult method(string param1, string param2) { .... } But in my situation an external website sends me a get request like: http://www.example.com/method?param.1=good&param.2=bad And in controller when i try to meet this request like as follow: public ActionResult method(string param.1, string param.2) { .... } I get build errors because

Why is unmodified template code in my MVC4 app trying to register areas twice?

核能气质少年 提交于 2019-12-13 06:48:25
问题 I have a new MVC4 app that I create off the MVC4 internet project template in VS11 beta. Now when I deploy the app to my web site hosting provider, and I leave the following line active in my Global.asax class, I get an error about MVC trying to register a route that already exists. When I comment out this line, everything runs fine, but action links to area specific controllers are broken, as I ask about in this question. AreaRegistration.RegisterAllAreas(); 回答1: If you have an old dll in

Correct terminology and examples for nesting/routing views in ASP.NET MVC

一曲冷凌霜 提交于 2019-12-13 06:15:50
问题 I have been doing ASP.NET for a while, and have done very little in MVC (in general), but very new at the ASP.NET MVC framework, as well as the correct terminology on a few things. Here is my example (actual application I am working on is different, but this is a public example I can use) - I want to create a simpler version of Redmine, but in .net. I want to list issues, in such a way that if I go to example.org/issues, I see a list of all issues (similar to http://www.redmine.org/issues),

Trying to setup root homepage using routing

北城余情 提交于 2019-12-13 05:23:42
问题 I am trying to set the root path of my domain http://www.example.com/ to the PersonSearch controller using the Routing module, but it doesn't seem to be having any effect (404 error). The URL http://www.example.com/person/search correctly takes me to the desired page. RouteConfig.cs public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); routes.MapRoute( "Root", "", defaults: new {