我遇到了奇怪的问题。我使用 Visual Studio 2012。当我开始从 .cshtml
选项卡调试我的 Web 应用程序时,我收到此错误
Server Error in '/' Application. The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/Header/GeneralInputs.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
当我从 .cs
选项卡运行它时,一切都很好并且运行良好。怎么了?
这是我的RouteConfig
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Header", action = "GeneralInputs", id = UrlParameter.Optional }
);
}
}
我还尝试将此行添加到 WebConfig
中,但这没有帮助
<modules runAllManagedModulesForAllRequests="true" />
更新:
我得到了什么
标题 Controller
public ActionResult GeneralInputs()
{
return View();
}
最佳答案
我认为您不能像这样请求此页面:请求的 URL/Views/Header/GeneralInputs.cshtml
。您应该请求Header/GeneralInputs
。您必须在 Controller 中请求操作。 Controller 中没有 View
关于c# - 无法从 .cshtml 选项卡运行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23166374/