ExternalSourceProvider

ExternalSourceProvider

我的控制器的Index()方法引用一种类型(ExternalSourceProvider),该类型在控制器的开头指定为成员:

ExternalSourceProvider externalSource;

// GET: Index
public ActionResult Index()
{
    externalSource = new ExternalSourceProvider();


我在ExternalSourceProvider()中遇到错误;在最后一行,说由于保护级别而无法访问。这是ExternalSourceProvider的定义:

public class ExternalSourceProvider
{
    ExternalSourceProvider() { }

    public string ExternalSiteAbsoluteURI { get; set; }


我想念什么?

最佳答案

您必须将默认构造函数标记为public。

public class ExternalSourceProvider
{
    public ExternalSourceProvider() { }

    public string ExternalSiteAbsoluteURI { get; set; }
}


目前,无法在此处访问

externalSource = new ExternalSourceProvider();

07-26 03:32