简体   繁体   中英

ASP.NET MVC changed view name

I changed the name of view files (Index.cshtml -> Performance.cshtml), and when I execute the project, the application can't recognise the new view name. I changed the name of an action in controller accordingly (ActionResult Index() -> ActionResult Performance()). However, it keeps saying HTTP 404 error.

Change the default route defined in App_Start/RouteConfig.cs file to set Performance as the default action.

Or, you can run the project with the following URL: http://localhost:port/home/Performance

When you change your view name mvc application can't find a proper view for it's controller action method.

If it is your default page view( load on application start) than you also need to make changes in your Route_config file.
See the image below 在此处输入图片说明 Change controller = " Name_of_controller" & action="name_of_action" in your case action name will be Performance .
Always Remember in mvc you can run any method using browser url
for example : controller is home & method is Performance than url will be localhost:port/home/Performance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM