小编Pro*_*ion的帖子

从不同的线程访问HttpContext.Current

我有一个C#ASP.NET应用程序,它启动了大约25个不同的线程,在一个名为SiteCrawler.cs的类中运行一些方法.

HttpContext.Current.Session我要保存用户所做的搜索结果,当所有线程都完成运行它呈现给用户.我的问题是该HttpContext.Current对象在生成的线程中为null,因为它不存在.

由于应用程序是多线程的限制,我还有什么其他选项来保存用户/会话特定数据而不使用会话?

我试图搜索Stackoverflow的每一寸都找到一个解决方案,但没有任何运气....

c# asp.net session httpcontext

53
推荐指数
5
解决办法
5万
查看次数

将Xml反序列化为对象时出错 - 不期望xmlns =''

我在尝试反序列化某些XML时遇到了麻烦,希望有人可以提供一些帮助.我已经阅读了很多类似的帖子,但我无法解决这个问题.

XML我试图反序列化

<register-account success="false">
  <user-name>xxxxx</user-name>
  <password>fghgh</password>
  <email>test@example.com</email>
  <error>
    <errorcode>120</errorcode>
    <errormessage>The password is invalid</errormessage>
  </error>
</register-account>
Run Code Online (Sandbox Code Playgroud)

我正在尝试将反序列化为:

[Serializable, XmlRoot(ElementName = "register-account", Namespace = "MyNamespace")]
[XmlType("register-account")]
public class RegisterAccountResponse
{
    [XmlAttribute("success")]
    public bool Success { get; set; } 

    /// <summary>
    /// Gets or sets the Tennant email address
    /// </summary>
    [XmlElement("email")]
    public string Email { get; set; }

    /// <summary>
    /// Gets or sets the tennant password
    /// </summary>
    [XmlElement("password")]
    public string Password { get; set; }

    /// <summary>
    /// Gets or …
Run Code Online (Sandbox Code Playgroud)

.net c# xml serialization deserialization

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

无法加载文件或程序集“System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一

在过去的几天里,我一直在拼命地试图解决依赖地狱的情况下,我钻进了安装里面加了一堆从新依赖性的NuGet包后System.Collections.*System.Diagnostics.*System.IO.*System.Runtime.*System.Text.*System.Threading.*System.Xml.*命名空间。MVC 项目我目前在目标 .Net 4.7.1 中有问题。

包安装将以下绑定重定向添加到我的 web.config

  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" …
Run Code Online (Sandbox Code Playgroud)

.net c# web-config visual-studio nuget

6
推荐指数
1
解决办法
5986
查看次数

jQuery $ .post成功函数永远不会触发

我有一个$ .post使用Fiddler我可以看到总是成功发布但我的成功函数永远不会被解雇.

成功发布到url的帖子返回1或者失败返回0,每次我测试它都会返回预期值1,所以我迷失了我做错了什么?

if ($('#mycheckbox').prop('checked')) {
    $.post('/base/MailingList/Subscribe/',
        {
            listId: $('#mycheckbox').val(),
            name: $('#subscriber-name').val(),
            email: $("#subscriber-email").val()
        },
        function(response) {
            console.log(response);
        });
}
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

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