Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在razor视图中列出所有成员资格用户_Asp.net_Asp.net Mvc 3_Razor_Asp.net Membership - Fatal编程技术网

Asp.net 在razor视图中列出所有成员资格用户

Asp.net 在razor视图中列出所有成员资格用户,asp.net,asp.net-mvc-3,razor,asp.net-membership,Asp.net,Asp.net Mvc 3,Razor,Asp.net Membership,在我的项目中,我正在使用带有MVC3的Razor。我使用会员资格来处理用户注册,并希望将所有用户放入表中 以下是我的行动: public ActionResult ListProfile() { //ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All); //return View(profiles);

在我的项目中,我正在使用带有MVC3的Razor。我使用会员资格来处理用户注册,并希望将所有用户放入
表中

以下是我的行动:

 public ActionResult ListProfile()
    {
        //ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
        //return View(profiles);
        var users = Membership.GetAllUsers();
        return View(users);
    }
我的看法是:

 @inherits System.Web.Mvc.ViewPage<MembershipUserCollection>
 @{
 ViewBag.Title = "Documents";
 }

<h2>Liste des documents</h2>
<table style="width: 100%;">
<tr>
    <th>Nom
    </th>
</tr>

@foreach (MembershipUser item in Model)
{
    <tr>
        <td>
            <h4>
                @item.UserName

            </h4>
        </td>


    </tr>
}

</table>
@继承System.Web.Mvc.ViewPage
@{
ViewBag.Title=“文档”;
}
文档列表
笔名
@foreach(模型中的MembershipUser项)
{
@item.UserName
}

但是我得到了一个错误:
CS0115:“ASP.\u Page\u Views\u AccountProfile\u listProfile\u cshtml.Execute()”:找不到合适的方法来覆盖

必须将基类型更改为
System.Web.Mvc.WebViewPage
,而不是
System.Web.Mvc.ViewPage
,因为razor配置处于
~/Views/Web.config

以下是视图:

  @inherits System.Web.Mvc.WebViewPage<MembershipUserCollection>
  @{
  ViewBag.Title = "Documents";
  }

  <h2>Liste des documents</h2>
  <table style="width: 100%;">
  <tr>
  <th>Nom
  </th>
  </tr>

  @foreach (MembershipUser item in Model)
  {
  <tr>
    <td>
        <h4>
            @item.UserName

        </h4>
    </td>


</tr>
}

</table>
@继承System.Web.Mvc.WebViewPage
@{
ViewBag.Title=“文档”;
}
文档列表
笔名
@foreach(模型中的MembershipUser项)
{
@item.UserName
}

看起来不错,有什么问题吗?我建议在var users=Membership.GetAllUsers()上设置一个断点;要查看填写的内容,并确保正确获取用户。抱歉,我刚刚用错误更新了我的帖子。这是web.config中的一个问题。可能重复:我以前看过这篇文章,但解决方法是在评论中。。。无论如何谢谢你