![](/img/trans.png)
[英]ASP.Net Core Web App - cshtml file can't invoke Controller method
[英]Can I use a .cshtml file as the LoginURL in an ASP.NET app?
当我的表单身份验证LoginURL是.asp页时,我的ASP.NET应用程序可以正常工作。 但是,我的应用程序的其余部分在Razor中,并且我无法获得与其他页面匹配的布局。 我尝试用CSHTML页面login.cshtml替换它,但在Visual Studio中收到此错误:
Warning 2 C:\Users\ddelgrande\Documents\Visual Studio 2010\Projects
\ABMCEditAndReports\ABMCEditAndReports\RazorLogin.cshtml:
ASP.NET runtime error: The pre-application start initialization method Start
on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an
exception with the following error message:
Exception has been thrown by the target of an invocation..
对于我在Visual Studio中打开的每个.CSHTML页面,该错误都会出现一次。
这是我的web.config中的Configuration / AppSettings值:
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
删除网页密钥不能解决问题。
请注意,我正在使用MVC 3。
我正在尝试做的事情甚至有可能吗?如果可以,我该如何解决这个问题?
好像您只需要在项目中引用“ ASP.NET Web页面”(如果我正确阅读此博客文章)一样,就可以将.cshtml
文件用作常规页面。
这为您提供了一个开始,但是它说安装webmatrix(argh!)。
http://www.asp.net/web-pages/tutorials/introducing-aspnet-web-pages-2/getting-started
如果您安装了nuget,则似乎确实有一个nuget软件包。
http://www.nuget.org/packages/Microsoft.AspNet.WebPages
不过不确定是否可以在mvc3中使用。 嗯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.