简体   繁体   English

启动MVC4基本模板项目

[英]Starting an MVC4 basic template project

I'm trying to start a new MVC4 C# project using the basic template, when I debug the project I get the "The resource cannot be found" error, how would I fix this so I just shows a blank page I can work on? 我正在尝试使用基本模板启动一个新的MVC4 C#项目,当我调试项目时,我得到“无法找到资源”错误,我将如何修复此问题,以便我只显示一个我可以处理的空白页面?

Thanks in advance. 提前致谢。

You need to add Controllers and View pages to just show something! 您需要添加控制器和查看页面才能显示某些内容!

Add HomeController : Controller file 添加HomeController:控制器文件

public string Index()
{
return "Hello";
}

if you run now, you will be able to see hello on the page 如果你现在跑,你将能够在页面上看到你好

The "Basic" template does not have any controllers or views in it. “基本”模板中没有任何控制器或视图。 You have to create at least a HomeController and an associated view for a page to be displayed. 您必须至少为要显示的页面创建HomeController和关联视图。 If you want an example application to start from that has something to view without adding anything choose the "Internet Application" template. 如果您希望从一个示例应用程序开始,无需添加任何内容即可查看,请选择“Internet应用程序”模板。 It creates a default HomeController and and Index view as well as account logon pages. 它创建一个默认的HomeController和Index视图以及帐户登录页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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