ASP.NET MVC"转换为Web申请表]选项​​缺少在Visual Studio [英] ASP.NET MVC "Convert to Web Application" option is missing in Visual Studio

查看:84
本文介绍了ASP.NET MVC"转换为Web申请表]选项​​缺少在Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Visual Studio 2008 SP1和ASP.NET MVC V1工作。当在视图上右击我不明白的选择转换为Web应用程序,我需要生成的.cs类落后code。我看到实际的项目和文件夹选项,而不是意见(ASPX文件)。我检查了ProjectTypeGuids有正确的价值观(?):

{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

任何其他建议,以可以看看有什么事?

感谢。

(我知道用code类背后用MVC设计影响)

P.S。要手工做这一切,你需要做的是:


  1. 添加文件具有相同的名称作为您的视图和的.cs(或.vb)扩展名,例如Index.aspx.cs。请确保您修改类从System.Web.Mvc.ViewPage或从继承其他类继承。

  2. 编辑ASPX文件,并添加到@Page指令codeBehind =Index.aspx.cs,改变继承到MyNamespace.Views.Home.Index(很明显,你需要有正确的$ C $ ç落后和命名空间有)。

  3. 右键点击aspx文件,并选择转换为Web应用程序。这将创建设计文件,同时修改您的.cs类并将其标记为部分。


解决方案

转换为Web应用程序是一个项目/文件级别的命令。你不能把它用在一个 ASPX 文件。

此外,别无他法自动化的方式(即我知道:-)),以code隐藏文件添加到一个ASPX文件。你必须做手工,自己加入相关文件,然后将其添加到.csproj的。

I'm working with Visual Studio 2008 SP1 and ASP.NET MVC v1. When right clicking on a view I do not get the option "Convert to Web Application" that I would need to generate code behind .cs classes. I see that option for the actual project and folders, but not for views (aspx files). I've checked the ProjectTypeGuids to have the "right" (?) values:

{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

Any other suggestions as to what I could look for?

Thanks.

(I am aware of design implications of using code behind classes with MVC)

P.S. To do it manually all you have to do is:

  1. Add a file with the same name as your view and the .cs (or .vb) extension, for example Index.aspx.cs. Make sure you modify your class to inherit from System.Web.Mvc.ViewPage or some other class that inherits from that.
  2. Edit the aspx file and add to the @Page directive CodeBehind="Index.aspx.cs" and change Inherits to "MyNamespace.Views.Home.Index" (obviously you need to have the right code behind and namespace there).
  3. Right click on the aspx file and choose Convert to Web Application. This will create the design file and also modify your .cs class and mark it as "partial".

解决方案

"Convert to web application" is a project/file-level command. You can't use it on a single ASPX file.

Also, there is no alternative automated way (that I know of :-)) to add code-behind files to an ASPX file. You have to do it manually, by adding the relevant files yourself and then adding them to the .csproj.

这篇关于ASP.NET MVC"转换为Web申请表]选项​​缺少在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆