在MAC使用MonoDevelop的开发ASP.NET MVC [英] Developing ASP.NET MVC using MonoDevelop on MAC
问题描述
我开发在MonoDevelop中使用ASP.NET MVC 2.0的Web应用程序。我有最新的单2.10和MonoDevelop的2.4.2,我运行它们在Mac上。
I am developing a web app using ASP.NET MVC 2.0 in MonoDevelop. I have latest Mono 2.10 and MonoDevelop 2.4.2 and I am running them on Mac.
据单的发行说明,它应该支持ASP.NET MVC 2.0。然而,我发现MonoDevelop的项目模板仍然只支持ASP.NET MVC 1.0。因此,我不得不从MonoDevelop的创建MVC项目,并从引用删除system.web.mvc 1.0.0.0和添加system.web.mvc 2.0.0.0回来了。我可以编写和编译code OK和MonoDevelop中确实提供了智能感知方法只有在MVC 2.0从C#和aspx文件都存在。然而,当我试图从MonoDevelop中运行它,我不得不编译错误抱怨。<%:Html.LabelFor(型号=> model.Name)%>作为LabelFor方法无法识别
According to mono’s release notes, it should support ASP.NET MVC 2.0. However, I found MonoDevelop’s project templates still only support ASP.NET MVC 1.0. So I had to create MVC project from MonoDevelop and remove system.web.mvc 1.0.0.0 from reference and add system.web.mvc 2.0.0.0 back in. I can write and compile code OK and MonoDevelop does provide intellisense for methods only exist in MVC 2.0 from both C# and aspx file. However, when I trying to run it from MonoDevelop, I had Compilation error complaining "<%: Html.LabelFor(model => model.Name) %>" as LabelFor method cannot be recognized .
MonoDevelop的使用XSP作为其测试Web服务器。我不知道它是如何配置我没有安装它自己。我认为这是安装为MonoDevelop中的一部分。我的猜测是XSP不知何故仍然采用MVC 1.0,但我不能证明这一点,因为我无法找到,即使安装它。
MonoDevelop uses XSP as its testing web server. I am not sure how it configured as I didn’t install it myself. I think it was installed as part of MonoDevelop. My guess is XSP somehow still uses MVC 1.0 but I can't prove it as I couldn’t even find where it is installed.
谁能帮我好吗?
更新:
我一直在怀疑的web.config了。这里是他们如何看像现在:
web.config中
Update: I have been suspecting web.config too. Here are how they look like now: web.config
<configuration>
<system.web>
<compilation defaultLanguage="C#" debug="true">
<assemblies>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<customErrors mode="RemoteOnly">
</customErrors>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
<authorization>
<allow users="*" />
</authorization>
在web.config文件的意见
web.config under views
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
推荐答案
设置为ASP.NET MVC ASP.NET项目需要更改,并在web.config中添加的设置的负载。在MD项目模板是ASP.NET MVC 1.0,而不是ASP.NET MVC 2,所以你可能缺少一些必要的设置,也许一个命名空间导入。
Setting up an ASP.NET project for ASP.NET MVC requires changing and adding a load of settings in web.config. The project template in MD is for ASP.NET MVC 1.0, not ASP.NET MVC 2, so you're probably missing some of the necessary settings, maybe a namespace import.
这篇关于在MAC使用MonoDevelop的开发ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!