不包含构造函数参数 - 错误 [英] does not contain a constructor argument - error

查看:202
本文介绍了不包含构造函数参数 - 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我想知道如何为以下代码设置参数,因为它当前正在输出编译错误 - 'user_feb2014.BasicAuthHandler'不包含带0参数的构造函数 - 错误。



Global.aspx类

Dear all,

I would like to know how can setup argument for the following code, as it currently outputting an compiling error - 'user_feb2014.BasicAuthHandler' does not contain a constructor that takes 0 arguments - error.

Global.aspx class

GlobalConfiguration.Configuration.MessageHandlers.Add(new BasicAuthHandler());



我尝试添加用户参数,但输出的错误更多。如果有人可以请我提供一些指导,那将非常有帮助。




I have tried adding user parameters but it outputs even more error. If someone could please provide me with some guidance, that would be very helpful.

public class BasicAuthHandler : DelegatingHandler
    {

        private const string BasicAuthResponseHeader = "WWW-Authenticate";
        private const string BasicAuthResponseHeaderValue = "Basic";

        private readonly iUser repository;

        public BasicAuthHandler(iUser repository)
      {
         this.repository = repository;
      }





非常感谢



Many thanks

推荐答案

您的构造函数需要参数:要加载到类中的存储库变量的iUser类/接口实例。



如果你没有可用的(我怀疑你需要找到一个)然后你将不得不创建一个不带参数的构造函数 - 但是你的存储库将会做什么变量后来是任何人的猜测。它可能会在系统后期导致失败。
Your constructor expects a parameter: an iUser class / interface instance to load into the repository variable in your class.

If you don't have one available (and I suspect you need to find one) then you will have to create a constructor that takes no arguments - but what that will do with your repository variable later is anybodies guess. It' will probably cause a failure later in the system.


这篇关于不包含构造函数参数 - 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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