" WebSecurity"在_AppStart.cshtml目前情况下误差不存在 [英] "WebSecurity" does not exist in the current context error in _AppStart.cshtml

查看:105
本文介绍了" WebSecurity"在_AppStart.cshtml目前情况下误差不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下编译错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'WebSecurity' does not exist in the current context

Source Error:


Line 1:  @{
Line 2:      if (!WebSecurity.Initialized)
Line 3:      {
Line 4:          WebSecurity.InitializeDatabaseConnection("AreaProject", "User", "UserId", "EmailAddress", autoCreateTables: true);

Source File: c:\Projects\area\trunk\dotNet\area.Web\area.Web\_AppStart.cshtml    Line: 2 
enter code here

我的项目是正确引用到的System.Web和我的其他文件正在使用System.Web.Security正在编制的罚款。

My project is correctly referencing to "System.Web" and my other files that are using " System.Web.Security" are compiling fine.

当我添加引用System.Web程序,System.Web.Pages和System.Web.Razor我的应用程序的启动问题。但我没有做任何更改WebMatrix.WebData或WebMatrix.Data。

The problem started when I added the references System.Web, System.Web.Pages and System.Web.Razor to my application. But I didn't make any change to WebMatrix.WebData or WebMatrix.Data.

推荐答案

这是正在这里引用的WebSecurity类是分开的<一个href=\"http://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity%28v=vs.111%29.aspx\"><$c$c>WebMatrix.WebData而不是的System.Web System.Web.Security 。你可能需要添加一个引用 WebMatrix.WebData.dll 和东西至少应该让过去的运行时编译错误。

The WebSecurity class that is being referenced here is apart of WebMatrix.WebData and not System.Web or System.Web.Security. You probably need to add a reference to WebMatrix.WebData.dll and things should at least get past the runtime compiler error.

您在运行时获取编译器错误,因为意见通常编译时,应用程序启动的第一次,而不是当组件遵守。

You get the compiler error at runtime because views are normally compiled when the application starts up for the first time, instead of when the assemblies are complied.

这篇关于&QUOT; WebSecurity&QUOT;在_AppStart.cshtml目前情况下误差不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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