简体   繁体   English

在Visual Studio 2010中将Webforms更改为MVC

[英]change webforms to mvc in visualstudio 2010

i created a blank webforms project instead of an MVC 3 project in visual studio, everything runs fine but i dont have my menues 我在Visual Studio中创建了一个空白的Webforms项目而不是MVC 3项目,一切运行正常,但我没有菜单

for example when i right click on the Controllers folder i dont get "Add a controller" option. 例如,当我右键单击Controllers文件夹时,我没有“添加控制器”选项。

does anyone know without starting a new project how to change the type of project into an MVC one so that i get the correct menus. 有谁知道不启动一个新项目,如何将项目类型更改为MVC,以便我获得正确的菜单。

thanks 谢谢

Try updating a MVC to ASP.NET Fall Update Release Candidate. 尝试将MVC更新为ASP.NET秋季更新发行候选版。 There is a link . 有一个链接

It's not that you don't have the menu options, it's that it's a completely different type of [web] application and works in different ways. 不是您没有菜单选项,而是它是[web]应用程序的一种完全不同的类型,并且以不同的方式工作。 eg Webforms has no concept of controllers so even if you did have a menu option it wouldn't get included in the project as you're expecting. 例如,Webforms没有控制器的概念,因此即使您具有菜单选项,也不会像您期望的那样将其包含在项目中。

Because webForms and MVC are so different there could never be a 100% reliable conversion utility. 由于webForms和MVC如此不同,因此永远不可能有100%可靠的转换实用程序。

Just create a new project and copy the files already created. 只需创建一个新项目并复制已创建的文件即可。 I can't imagine you've written that much code before realising that you're in WebForms, not MVC. 我无法想象您在意识到使用WebForms而不是MVC之前已经编写了那么多代码。

If you have got lots of WebForms code you could always just include this in the MVC project until you can convert it (if necessary) at a later time. 如果您有很多WebForms代码,则可以始终将其包含在MVC项目中,直到以后可以转换(如有必要)为止。

Edit: 编辑:
If you just want to change the project type you can edit the csproj file of the webforms project and add the following ProjectTypeGuid {F85E285D-A4E0-4152-9332-AB1D724D3325}; 如果您只想更改项目类型,则可以编辑webforms项目的csproj文件并添加以下ProjectTypeGuid {F85E285D-A4E0-4152-9332-AB1D724D3325}; .
You'll need to update references, files, etc. for this to work but it may be quicker than creating a new project and copying content over. 您需要更新引用,文件等才能使其正常工作,但是它可能比创建新项目和复制内容更快。 (Especially if you already have the project in source control.) (特别是如果您已经在源代码管理中拥有该项目。)

Note that I've only tested this going from WebForms 4 to MVC2. 请注意,我只测试了从WebForms 4到MVC2的测试。

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

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