我在我的应用程序中使用了OWIN身份验证.
登录操作
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName));            
claims.Add(new Claim(ClaimTypes.Sid, result.UserID.ToString()));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
我想从不同的操作访问UserName和UserID.如何访问声明中添加的值?
更新 我试过了
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName + " " + result.UserLastName));            
claims.Add(new Claim(ClaimTypes.Sid, result.UserIDNumber.ToString()));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
var authenticationManager = Request.GetOwinContext().Authentication;
authenticationManager.SignIn(identity);
var claimsPrincipal = new ClaimsPrincipal(identity);
Thread.CurrentPrincipal = claimsPrincipal;

我可以在快速窗口中查看值.但即使我无法访问该值.如何获得价值?
我想在foreach之外添加一个变量,我应该在foreach循环中访问该变量
<table class="generalTbl">
    <tr>
        <th>Date</th>
        <th>Location</th>
    </tr>
    @int i;
    @foreach (var item in Model)
    {
      i=0;
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.DueDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.location)
            </td>
        </tr>
    }
</table>
上面的例子我添加了@int i; 在foreach之外我尝试在foreach中访问它,就像i = 0; 但它显示" 当前上下文中不存在名称'i' "
如何访问循环内的变量?
我正在将QuickBooks(桌面版)与ASP.NET应用程序集成.为此,我使用的是QuickBooks Web Connector.如何为自定义Web服务创建.qwc文件?
我想将字符串值转换为日期时间
类
public class demoDate
{
    public DateTime DueDate;
    public int OrderReportID;
    public DateTime _DueDate 
    { 
        get { return DueDate; } 
        set { DueDate = value; } 
    }
    public int _OrderReportID 
    { 
        get { return OrderReportID; } 
        set { OrderReportID = value;} 
    }
}
询问
var DateQuery = (from o in db.Order_Reports
                 select new demoDate {
                    DueDate = System.DateTime.Parse(o.ReportDueDateTime), 
                    OrderReportID = o.OrderReportID
                 }).ToList();
此编码显示以下错误
LINQ to Entities无法识别方法'System.DateTime Parse(System.String)'方法,并且此方法无法转换为存储表达式.
这是我的编码.它显示错误,如在提供程序连接上启动事务时发生错误.有关详细信息,请参阅内部异常
       DemoEntities db = DemoEntities.CreateNewDemoEntity();
       var query = (from f in db.Product_Table
                    where f.ReportID == reportID && f.StateID == stateID
                    select f);
       foreach(var q in query)
       {
           Custom_Search_Transformation cst = new Custom_Search_Transformation()
           {
               CustomerID = customerID,
               StateID = stateID,
               FullProductID = q.FullProductID
           };
           db.Custom_Search_Transformation.AddObject(cst);
           db.SaveChanges();
       }
我使用InvoiceQueryRq获取发票详细信息.它从quickbooks中获取所有信息.但我需要根据条件获取数据.如何在InvoiceQueryRq中使用过滤器选项?
我想将 quickbooks 与我的 Windows 服务集成。目前我正在使用quickbooks SDK。它与 Windows 应用程序一起使用。在 Windows 服务中,它显示“无法启动 QuickBooks”。例外。
如何解决这个问题
在MVC 5中,如何为表创建分页?以下是表结构.
<table class="table">
    <tr>
        <th>
           Item ID
        </th>
        <th>
           Item Name
        </th>
        <th>
           Rate
        </th>
        <th>
          Stock
        </th>
    </tr>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ItemID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ItemName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Rate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Stock)
        </td>
    </tr>
}    
</table>
c# ×4
asp.net-mvc ×3
qbxml ×3
quickbooks ×3
linq ×2
razor ×2
.net ×1
asp.net ×1
claims ×1
datetime ×1
declaration ×1
foreach ×1
html-table ×1
pagination ×1
qbwc ×1
xml ×1