gpt4 book ai didi

c# - 无法从 .cshtml 选项卡运行应用程序

转载 作者:行者123 更新时间:2023-11-30 22:07:11 29 4
gpt4 key购买 nike

我遇到了一个奇怪的问题。我使用 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();
}

最佳答案

我认为你不能像这样请求这个页面:Requested URL/Views/Header/GeneralInputs.cshtml。您应该请求 Header/GeneralInputs。您必须在 Controller 中请求操作。 Controller 中没有 View

关于c# - 无法从 .cshtml 选项卡运行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23166374/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com