57得票5回答
从不同线程访问HttpContext.Current

我有一个C# ASP.NET应用程序,启动了大约25个不同的线程来运行SiteCrawler.cs类中的一些方法。 在HttpContext.Current.Session中,我想保存用户进行的搜索结果,并在所有线程完成运行后向用户呈现它。我的问题是,在派生的线程中,HttpContext....

54得票4回答
Request.UserHostAddress问题返回结果为“::1”

我试图使用以下方法获取客户端的IP地址: HttpContext.Request.UserHostAddress; 但它返回::1。 如何解决?

52得票3回答
不使用HttpContext获取应用程序路径(ASP.NET)

如何做到? 我不想使用这个方法:HttpContext.Current.Server.MapPath 是否有类似的函数可以在不需要httpcontext的情况下调用? 例如,如果我启动一个线程来执行一些任务,我无法使用httpcontext,但仍然需要获取应用程序的路径。而且,我不能将上下...

51得票11回答
HttpContext.Current.User.Identity.Name为空。

我有一个使用MVC框架的Silverlight应用程序,在Visual Studio中进行构建时,使用Visual Studio Development center没有问题,HttpContext.Current.User.Identity.Name返回了值。 但是当我在IIS 7.5上使...

51得票8回答
HttpContext.Current.User.Identity.Name怎么知道哪些用户名存在?

这并不一定是一个问题,我只是想知道它是如何工作的。我有一个方法:public static bool UserIsAuthenticated() { bool isAuthed = false; try { if (HttpContext.Current...

48得票3回答
HttpContext.Current.Request.Url.Host返回什么?

我有一个本地应用程序,其路径为:http://localhost:950/m/pages/Searchresults.aspx?search=knife&filter=kitchen 但是当这个东西进入集成环境或者生产环境时,它将会变成这样:http://www.someshoppin...

45得票5回答
如何在服务器端Blazor中访问HttpContext?

我需要在一个页面(.cshtml文件)中访问HttpContext,特别是请求和一个cookie。尽管可用,但HttpContextAccessor始终在其HttpContext属性中存储null值。 非常感谢您的任何建议。 提前致谢。 编辑:我使用的Blazor版本是:0.7.0。

43得票6回答
使用HttpContext OutputStream写入ZipArchive

我一直在尝试让.NET 4.5中包含的“新”ZipArchive(System.IO.Compression.ZipArchive)在ASP.NET网站上运行。但似乎它不喜欢写入HttpContext.Response.OutputStream的流。 我的下面示例代码将抛出 Sys...

42得票3回答
正确使用HttpContext.Current.User与异步等待的方法

我正在使用异步操作,并像这样使用HttpContext.Current.Userpublic class UserService : IUserService { public ILocPrincipal Current { get { return HttpCont...

42得票4回答
elmah:没有HttpContext的异常?

我在Application_Start中生成一个线程,并希望记录异常。没有Context/HttpContext/HttpContext.Current,那么我该如何记录日志呢? 目前,它不会捕获任何线程中的异常,如果我写ErrorSignal.FromCurrentContext().Ra...