MVC3 start page

2019-06-16 21:21发布

问题:

I am working on a web app in Visual Studio 2010, its mvc3. I Was trying to figure out how to publish it, and through various instructions I tried setting View/Home/Index as the start page. This was a bad idea. Now nothing is working, even trying to view the site as I have been (debugging with F5) is not loading properly.

I don't know what the start page was before, or how to undo this. I am very new to web development, and a little lost right now. How do I get my start page back?

回答1:

Try setting the start page to /.



回答2:

  1. Go to the project's Properties
  2. Go to the Web tab
  3. Select the Specific Page radio button
  4. Remove url in the Specific Page text box
  5. Save Properties Tab.


回答3:

If you leave it alone after set up, it should be like so:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

My suggestion is leave it like that. How do you "get back"?

Simple: Open another instance of Visual Studio. Create a blank MVC3 project. Copy over the routing rules and add custom rules (if any) below. Copy over the web.config with any customizations you have made (if any).

Then, right click the project and select publish. If you publish to a local folder, you will have to set up IIS properly, but you can work through the kinks on your local IIS instance (assume you have installed it, as this is a developer machine?). Once you know the set up, you can move to the server and you should be fine.

That is about all of the time I have for this one right now. Good luck!



回答4:

i know this is an old post... but whoever comes after this would find the piece of info helpful

if you want to change the start up page in MVC3 u can do so by just specifying like this

Specify Page: Account/Logon

No need to include the view name if you say Views/Account/LogOn it would return Resource not found error and if you include / it would say bad request.

I tried the above option and could change my start up page from the annoying index page to LogOn.cshtml



回答5:

Simply change your starting url to /Home/Index or / (or remove it) - you cannot address items directly in the /Views folder.



回答6:

Try creating a new html file in the main project and set it as the default. Then delete the file. That should remove the start page. You do not need one for Mvc.



回答7:

  1. Right click on project --> Properties
  2. Go to the Web tab
  3. Select the Specific Page radio button
  4. Specify the start page as ControllerName/ActionName as it comes in the browser url when the page is loaded
  5. Save.