Asp.net 为什么它找不到我的模块?
可能重复:Asp.net 为什么它找不到我的模块?,asp.net,asp.net-mvc-4,basic-authentication,Asp.net,Asp.net Mvc 4,Basic Authentication,可能重复: 我正在尝试创建自己的基本身份验证实现 我的solution\Modules中存储了BasicAuthenticationModule.cs,其命名空间为: namespace Web_API.Modules { public class BasicAuthenticationModule : IHttpModule 我已将其添加到我的web.config中,如下所示: <system.webServer> <modules>
我正在尝试创建自己的基本身份验证实现 我的
solution\Modules
中存储了BasicAuthenticationModule.cs
,其命名空间为:
namespace Web_API.Modules
{
public class BasicAuthenticationModule : IHttpModule
我已将其添加到我的web.config中,如下所示:
<system.webServer>
<modules>
<add name="MyBasicAuthenticationModule" type="Web_API.Modules.BasicAuthenticationModule, BasicAuthenticationModule" />
我在这里做错了什么?您似乎为模块指定了错误的程序集名称。当你写作时:
type="Web_API.Modules.BasicAuthenticationModule, BasicAuthenticationModule"
这意味着在名为BasicAuthenticationModule
的程序集中的Web\u API.Modules
命名空间中加载名为BasicAuthenticationModule
的类。您在其中定义此类的项目名为BasicAuthenticationModule
?我想不是。这就是ASP.NET无法加载模块的原因。您应该指定定义此模块的正确程序集名称
例如,如果ASP.NET MVC应用程序名为MVCAPApplication1
,则定义可能如下所示:
type="Web_API.Modules.BasicAuthenticationModule, MvcApplication1"
type="Namespace.ClassName, AssemblyName"
type属性的格式如下所示:
type="Web_API.Modules.BasicAuthenticationModule, MvcApplication1"
type="Namespace.ClassName, AssemblyName"
您似乎为模块指定了错误的程序集名称。当你写作时:
type="Web_API.Modules.BasicAuthenticationModule, BasicAuthenticationModule"
这意味着在名为BasicAuthenticationModule
的程序集中的Web\u API.Modules
命名空间中加载名为BasicAuthenticationModule
的类。您在其中定义此类的项目名为BasicAuthenticationModule
?我想不是。这就是ASP.NET无法加载模块的原因。您应该指定定义此模块的正确程序集名称
例如,如果ASP.NET MVC应用程序名为MVCAPApplication1
,则定义可能如下所示:
type="Web_API.Modules.BasicAuthenticationModule, MvcApplication1"
type="Namespace.ClassName, AssemblyName"
type属性的格式如下所示:
type="Web_API.Modules.BasicAuthenticationModule, MvcApplication1"
type="Namespace.ClassName, AssemblyName"
在保存类的磁盘上,程序集是如何命名的?@rene您能指定吗?保存类的项目有一个输出文件名,因为它是在dll中编译的。我怀疑dll的名称不是BasicAuthenticationModule,可能是Web_API或类似的名称。为什么要遵循MVC4项目的ASP.NET 2.0教程?在保存类的磁盘上,程序集的名称如何?@rene请指定?保存类的项目有一个输出文件名,因为它是在dll中编译的。我怀疑dll的名称不是BasicAuthenticationModule,可能是Web_API或类似的名称。为什么要遵循MVC4项目的ASP.NET 2.0教程?现在im GENT的值不能为null。参数名称:my module中以下项的typeName:“字符串提供程序=ConfigurationManager.AppSettings[“Web_API.Modules.BasicAuthenticationModule.AuthProvider”];Type providerType=Type.GetType(provider,true);'提供程序为空,我必须在某个地方定义它吗?嗯,您似乎已经定义了一些
Web\u API.Modules.BasicAuthenticationModule.Authweb.config文件中指向某个运行时类型的提供程序
设置。确保它也遵循“Namespace.ClassName,AssemblyName”
模式,并且该类型确实存在。很难说,但至少现在你的模块被加载并执行了,这是你最初的问题。我做了一个粗略的猜测,它工作了…@DarinDimitrov他可能也做了
?现在我得到了“值不能为空。参数名称:my module中以下项的typeName:“字符串提供程序=ConfigurationManager.AppSettings[“Web_API.Modules.BasicAuthenticationModule.AuthProvider”];Type providerType=Type.GetType(provider,true);'提供程序为空,我必须在某个地方定义它吗?嗯,您似乎已经定义了一些Web\u API.Modules.BasicAuthenticationModule.Authweb.config文件中指向某个运行时类型的提供程序
设置。确保它也遵循“Namespace.ClassName,AssemblyName”
模式,并且该类型确实存在。很难说,但至少现在你的模块被加载并执行了,这是你最初的问题。我做了一个大胆的猜测,它工作了…@DarinDimitrov他也能做
?