小编Ero*_*ocM的帖子

'System.Web.Mvc.HtmlHelper'没有名为'Partial'的适用方法

我收到此错误:

错误CS1973:'System.Web.Mvc.HtmlHelper'没有名为'Partial'的适用方法,但似乎有一个名称的扩展方法.无法动态分派扩展方法.考虑转换动态参数或调用扩展方法而不使用扩展方法语法."}

从我在这里读到的Razor View Engine:表达式树可能不包含动态操作,因为它使用的是我正在使用Session的viewbag(?).

这是我的网络表单:

@using SuburbanCustPortal.MiscClasses

@{
    ViewBag.Title = "Account Screen";
 }

<h2>AccountScreen</h2>

<div class="leftdiv">
  <fieldset>
    <legend>Customer Info</legend>
    @Html.Partial("CustomerInfo")
  </fieldset>

  <fieldset>
    <legend>Delivery Address</legend>
    @Html.Partial("DeliveryAddress")
  </fieldset>

  <fieldset>
    <legend>Delivery Info</legend>
    @Html.Partial("DeliveryInfo")
  </fieldset>
</div>

<div class="rightdiv">
  <fieldset> 
    <legend>Balance</legend>
      @Html.Partial("AccountBalance")
  </fieldset>

             @if (SessionHelper.ShowPaymentOptions || SessionHelper.ShowHistory)
             {
               <fieldset>
                 <legend>Account Options</legend>
                 <br/>

                 @using (Html.BeginForm("AccountScreenButton", "Customer", FormMethod.Post))
                 {
                   <div class="sidebysidebuttons">
                     <div class="box">
                       @if (SessionHelper.ShowHistory && SessionHelper.ShowAccountScreenPaymentButton)
                       {
                         <button class="sidebysidebutton1" name="options" value="payment">Make a Payment</button>
                         <button class="sidebysidebutton2" name="options" value="activity">Display Activity</button>
                       }
                       else
                       {
                         if (SessionHelper.ShowAccountScreenPaymentButton) …
Run Code Online (Sandbox Code Playgroud)

c# debugging asp.net-mvc-3

22
推荐指数
1
解决办法
2万
查看次数

会员凭证验证问题在不应该使用时失败

由于我们的网站无法直接使用信用卡,因此我们会将凭证和其他misc变量的用户路由到另一个网站上的"托管页面".

为了更详细,这是用户通常如何访问它:

  1. 转到我们的网站并使用他们之前创建的用户名和密码登录.这使用asp.net成员资格提供程序.

  2. 登录后,我们会向他们显示他们的帐户,并且他们有一个按钮来进行付款.一旦他们点击这个......

  3. 系统会提示他们使用"预付款"页面来验证金额和其他各种信息.他们点击这里继续......

  4. 因此,付款页面显示在我们网站的iframe中.我们使用以下代码将它们重定向到外部托管网页:

    <div align ="center"> <iframe width ="100%"height ="600px"src ="@ Html.Raw(@ ViewBag.GateWayWebsite)"> </ div>

  5. 输入付款页面并且客户点击提交后,该网站会将帖子提交回我们开始的网站并传回有关费用的信息.我抓住这些信息并将其保存到我们的数据库并显示收据.

一切都很好,除了#5.这大部分时间都有效,但大约有十分之一的人回来了这条消息:

Event code: 4006 
Event message: Membership credential verification failed. 
Event time: 12/16/2013 4:32:22 AM 
Event time (UTC): 12/16/2013 12:32:22 PM 
Event ID: 42c509f2a25d46f0af17e72a52dfbbe5 
Event sequence: 38 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/3/ROOT/SuburbanCustPortal-1-130316693110399868 
    Trust level: Full 
    Application Virtual Path: /SuburbanCustPortal 
    Application Path: C:\inetpub\wp\SuburbanCustPortal\ 
    Machine name: WIN-OB929P97YAR 

Process information: 
    Process ID: 3620 
    Process name: …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc membership-provider

18
推荐指数
1
解决办法
6109
查看次数

在PowerShell中输出日期/时间

我想在我的脚本中的各个位置输出日期时间以进行日志记录,所以我这样做:

$b = Get-Date
Write-Output "Backups complete at $b"

# more code here

$c = Get-Date
Write-Output "Backups complete at $c"
Run Code Online (Sandbox Code Playgroud)

我不得不使用多个字母表来获取最新的日期/时间.

是否有更简单的方法来执行此操作,或者每次我想再次使用它时是否必须重新建立日期?

powershell powershell-4.0

16
推荐指数
3
解决办法
3万
查看次数

无法进入我的解决方案中的本地服务

我知道之前已经问过这个问题,但我无法弄清楚这一点.我相信我已经涵盖了已经提出的所有内容,但我会介绍这些内容.

当我尝试进入一个当前在我的解决方案中的项目的服务时,我收到此消息:

在此输入图像描述

我的解决方案中有3个项目:

SuburbanCustPortal < - 我的网站SuburbanHub < - 我的serice WebsiteLogging < - 我的日志项目(这里没有意义)

我读到我应该检查以下项目:

  1. 确保已启用调试.我在我的项目的web.config中都有这个:

  2. 确保它们都使用相同的.net版本.它们都在.net框架4.0上.

  3. 确保未选中"仅启用您的代码":

在此输入图像描述

该服务指向本地URL:

在此输入图像描述

我可以在浏览器中启动服务而不会出现错误:

在此输入图像描述

这是我对iis的设置:

在此输入图像描述

我重新启动了visual studio,计算机并删除了服务并将其添加回来.

在我的生活中,我不能想到这一点.如果我错过了什么,我愿意试一试.

我得到这个解决是非常重要的,所以我可以在本周末结束这个项目,所以任何帮助将不胜感激.

对Sanket Shah的回应

我没有选项w3wp.exe:

在此输入图像描述

有些我忘记了

我在两个项目中都设置了debug = true:

<compilation targetFramework="4.0" debug="true">
  <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>
Run Code Online (Sandbox Code Playgroud)

此外,我想补充一点,我之前已经能够进入我的服务,但自从最近回到该项目后,我也无法做到.我在调用该服务的行上有一个断点,当我尝试使用F11时,我得到了上述消息.

对帕维尔的反应

我尝试过以下方式设置符号,但我也没允许我介入:

在此输入图像描述在此输入图像描述

我甚至尝试使用Microsoft符号:

在此输入图像描述

对#2 Pawel的回应

在此输入图像描述

附加信息

我刚注意到这一点,我不确定它是否相关:

在此输入图像描述

关于调试模式的补充信息

我将所有项目设置为调试模式:

在此输入图像描述

c# asp.net-mvc visual-studio-2013

14
推荐指数
1
解决办法
1230
查看次数

Razor View IsAuthenticated没有按预期工作

我创建了一个简单的MVC应用程序,它使用随新项目提供的.Net Membership Provider.

我试图让标签正确显示.我可能听不懂,但这是我的代码:

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <div id="header">
            <div id="title">
                <h1>Suburban Customer Portal</h1>
            </div>
            <div id="logindisplay">
                @Html.Partial("_LogOnPartial")
            </div>
            <div id="menucontainer">
              <ul id="menu">

                @if (Request.IsAuthenticated)
                {
                  <li>@Html.ActionLink("ChangePassword", "ChangePassword", "Account")</li>
                }else { 
                  <li>@Html.ActionLink("Logon", "Logon", "Account")</li>
                  <li>@Html.ActionLink("Register", "Register", "Account")</li>
                }

                  <li>@Html.ActionLink("ContactUs", "ContactUs", "Home")</li>
              </ul>
            </div>
        </div>
        <div id="main">
            @RenderBody()
        </div>
        <div id="footer">
        </div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在这一行:

@if (Request.IsAuthenticated)
Run Code Online (Sandbox Code Playgroud)

我正在尝试显示正确的标签,如果它们已经过身份验证.这总是真实的......

我该怎么做?我显然没有以正确的方式做到这一点......

再次感谢!

c# asp.net-mvc razor

13
推荐指数
1
解决办法
9386
查看次数

C#标签文本未更新

我有以下代码:

private void button1_Click(object sender, EventArgs e)
{
  var answer =
    MessageBox.Show(
      "Do you wish to submit checked items to the ACH bank? \r\n\r\nOnly the items that are checked and have the status 'Entered' will be submitted.",
      "Submit",
      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
      MessageBoxDefaultButton.Button1);

  if (answer != DialogResult.Yes)
    return;

  button1.Enabled = false;
  progressBar1.Maximum = dataGridView1.Rows.Count;
  progressBar1.Minimum = 0;
  progressBar1.Value = 0;
  progressBar1.Step = 1;

  foreach (DataGridViewRow row in dataGridView1.Rows)
  {
    if ((string) row.Cells["Status"].Value == "Entered")
    {
      progressBar1.PerformStep();

      label_Message.Text = @"Sending " + row.Cells["Name"].Value …
Run Code Online (Sandbox Code Playgroud)

c# label sleep winforms

12
推荐指数
3
解决办法
3万
查看次数

C#基于硬件ID创建唯一ID

我正在创建一个特定于机器的许可证.许可证基于以下项目:

  1. MAC地址
  2. CPU序列号
  3. 计算机卷序列号drive0

我假设如果3匹配中的2个,那么我的许可证是有效的.因此,可以获得新的网卡,许可证仍然有效,等等.

这是一个很好的方法还是我会遇到与此不匹配或经常更改的问题?

我正在尝试获取计算机的唯一标识符,以便我可以验证许可证.

请告诉我这看起来如何,或者你有更好的解决方案!

再次感谢!

**这是我用什么来表达**

我最终只使用了VolumeSerial,CpuId和VideoControllerDescription.

    public enum HardwareProfileComponents
    {
        ComputerModel,
        VolumeSerial,
        CpuId,
        MemoryCapacity,
        VideoControllerDescription
    }

    public static Dictionary<string, string> HardwareProfile()
    {
        var retval = new Dictionary<string, string>
                         {
                             {HardwareProfileComponents.ComputerModel.ToString(), GetComputerModel()},
                             {HardwareProfileComponents.VolumeSerial.ToString(), GetVolumeSerial()},
                             {HardwareProfileComponents.CpuId.ToString(), GetCpuId()},
                             {HardwareProfileComponents.MemoryCapacity.ToString(), GetMemoryAmount()},
                             {HardwareProfileComponents.VideoControllerDescription.ToString(), GetVideoControllerDescription()}
                         };
        return retval;

    }

    private static string GetVideoControllerDescription()
    {
        Console.WriteLine("GetVideoControllerDescription");

        var s1 = new ManagementObjectSearcher("select * from Win32_VideoController");
        foreach (ManagementObject oReturn in s1.Get())
        {
            var desc = oReturn["AdapterRam"];
            if ( desc == null) continue;
            return oReturn["Description"].ToString().Trim(); …
Run Code Online (Sandbox Code Playgroud)

c# hardware licensing

12
推荐指数
3
解决办法
1万
查看次数

MVC Razor按钮单击甚至传递参数

我是MVC Razor的新手.

我有这个观点:

@model SuburbanCustPortal.Models.CustomerModel

@{
    ViewBag.Title = "Customer Summary";
}

<h2>Customer Summary Screen</h2>
<p>
    Please select an account below or add an existing account.
</p>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
  @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.")

  <div>
    <fieldset>
      <legend>Existing Accounts</legend>

      @Html.Action("ExistingAccounts2")

      <p>
        <input type="submit" value="Add an Account" />
      </p>


    </fieldset>
  </div>
}
Run Code Online (Sandbox Code Playgroud)

哪个调用此方法:

[Authorize]
public ActionResult ExistingAccounts2()
{
  return PartialView("ExistingAccounts", _client.RequestCustomersForAccount(User.Identity.Name));
}
Run Code Online (Sandbox Code Playgroud)

反过来调用这个局部视图:

@model IEnumerable<SuburbanCustPortal.SuburbanService.CustomerData >

<br />
<br …
Run Code Online (Sandbox Code Playgroud)

.net html c# asp.net-mvc razor

11
推荐指数
1
解决办法
8万
查看次数

防止后退按钮

我在使用C#的ASP.NET MVC上使用Razor.

我打电话给外部网页处理信用卡,然后它返回给我.然后我显示收据.

我想阻止他们回到上一个屏幕.

我没有底层的cs页面,比如asp,因为这些是.cshtml文件,来抓住这个事件.

此收据页面是一个视图,因此我不能将JavaScript放在标题中,因为它会影响使用它的每个页面.

有人知道我在这种情况下如何阻止后退按钮?

c# asp.net-mvc back-button razor

10
推荐指数
2
解决办法
2万
查看次数

datagridview绑定到不更新数据库的实体

我正在从实体对象填充网格,它正在显示数据.当我进行更改并将其保存回来时,没有任何更新.

这是我的代码:

在我的加载事件中:

  var query = from c in _entities.PaymentTypes
              where c.CorporationId == _currentcorp.CorporationId
              select
                new DataBindingProjection
                  {
                    PaymentTypeId = c.PaymentTypeId,
                    CorporationId = c.CorporationId,
                    TokenId = c.TokenId,
                    IsActive = c.IsActive,
                    Description = c.Description,
                    CashChargeCodeType = c.CashChargeCodeType,
                    SortOrder = c.SortOrder,
                    ExcludeCreditCode = c.ExcludeCreditCodes,
                    IsUpdated = c.IsUpdated,
                    IsAdded = c.IsAdded,
                    ClearUpdatedAndAdded = c.ClearUpdateAndAdded
                  };
  dataGridView_PaymentTypes.DataSource = query.ToList();
Run Code Online (Sandbox Code Playgroud)

我的课:

private class DataBindingProjection
{
  public Guid PaymentTypeId { get; set; }
  public Guid CorporationId { get; set; }
  public Guid TokenId { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework datagridview winforms

9
推荐指数
1
解决办法
1万
查看次数