找不到类型或名称空间名称"WebContext"(您是否缺少using指令或程序集引用?) [英] The type or namespace name 'WebContext' could not be found (are you missing a using directive or an assembly reference?)
本文介绍了找不到类型或名称空间名称"WebContext"(您是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的app.xaml中,我添加了用于创建登录页面的这些代码
这里的代码:
公共 App()
{
this .Startup + = this .Application_Startup;
此.退出+ = 此 .Application_Exit;
此 .UnhandledException + = 此 .Application_UnhandledException;
InitializeComponent();
setAuthenticationContext();
}
私有 无效 setAuthenticationContext()
{
var webcontext = 新 WebContext
{
验证=
新 FormsAuthentication()
};
此 .ApplicationLifetimeObjects.Add(webcontext);
}
但是我在webcontext上有错误,请帮助我解决它
解决方案
作为 ^ ],则必须引用System.Web
程序集(在Visual Studio
上的菜单项Project->Add reference...
).
在new WebContext
行添加()"var webcontext = 新 WebContext () { 验证= 新 FormsAuthentication() };
in my app.xaml i added these codes for making a login page
here the codes:
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
setAuthenticationContext();
}
private void setAuthenticationContext()
{
var webcontext = new WebContext
{
Authentication =
new FormsAuthentication()
};
this.ApplicationLifetimeObjects.Add(webcontext);
}
but i have a error on webcontext , plz help me to solve it
解决方案
As the documentation states[^], you have to put a reference to theSystem.Web
assembly (onVisual Studio
, menu itemProject->Add reference...
).
Add "()" at the linenew WebContext
var webcontext = new WebContext() { Authentication = new FormsAuthentication() };
这篇关于找不到类型或名称空间名称"WebContext"(您是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文