我有一个C#ASP.NET应用程序,它启动了大约25个不同的线程,在一个名为SiteCrawler.cs的类中运行一些方法.
在HttpContext.Current.Session我要保存用户所做的搜索结果,当所有线程都完成运行它呈现给用户.我的问题是该HttpContext.Current对象在生成的线程中为null,因为它不存在.
由于应用程序是多线程的限制,我还有什么其他选项来保存用户/会话特定数据而不使用会话?
我试图搜索Stackoverflow的每一寸都找到一个解决方案,但没有任何运气....
我在尝试反序列化某些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) 在过去的几天里,我一直在拼命地试图解决依赖地狱的情况下,我钻进了安装里面加了一堆从新依赖性的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) 我有一个$ .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) c# ×3
.net ×2
ajax ×1
asp.net ×1
httpcontext ×1
javascript ×1
jquery ×1
nuget ×1
session ×1
web-config ×1
xml ×1