httpcontext

Multi-Threading, HttpContext, Long Running Task?

Hi, I got started with threads Thread.Start() recently and Long Running Tasks and noticed several request related issues. EDIT What would you suggest to provide the user a feedback while the job is being processed, make efficient use of the thread pool and make use of HttpContext if possible? ...

When Is HttpContext.User initialized?

When is the earliest point in which I can access HttpContext.User? ...

Why is HttpContext.Request.Url not matching what's in the address bar?

Ok, so I want to force https/ssl on parts of my ASP.NET MVC site. Found lots of great sources including an ActionFilter here: http://blog.tylergarlick.com/index.php/2009/07/mvc-redirect-to-http-and-https/ Whenever I enable the ActionFilter however I end up in a redirect loop. The problem is that if I type https://www.mysite.com/ into th...

ASP.NET Session is not keeping stored across pages

First, I created a Login page that added a key value pair to the session and verified that on that page the session holds that pair. Next, I attempt to go to another page that looks for that pair in the session and it is not there. I've put the timeout for the session to 15000 so it won't timeout. I currently use a static class to look a...

ASP.NET MVC: How to use HttpContext.User

Im getting really lost on how to use HttpContext.User. I read everywhere that its great for FormAutherication, but i just cant see how it works. If i do something like this: ControllerContext.HttpContext.User = new GenericPrincipal(GetUser(username, password), roles); What does ControllerContext.HttpContext.User contain? and how do i ...

Get HttpContext from JQuery AJAX GET

Hello... My project is using Castle Monorail as a MVC framework. The problem is that Monorail requires that all controllers have a view template. I am trying to get a string back from a method on a controller via an AJAX call. The AJAX GET always returns a 500 error from the server because Monorail cannot find a view template. I have se...

SubSonic - Class Library Project?

In the SubSonic docs it lists: o By default, the Tool generates insert and update code that uses System.Web.HttpContext.Current.User.Identity.Name and System.Threading.Thread.CurrentPrincipal.Identity.Name. Some generated methods may also make use of System.Web classes. If you don’t want to have to add a reference to System.Web in yo...

How do I mock the HttpContext in ASP.NET MVC using MOQ?

[TestMethod] public void Home_Message_Display_Unknown_User_when_coockie_does_not_exist() { var context = new Mock<HttpContextBase>(); var request = new Mock<HttpRequestBase>(); context .Setup(c => c.Request) .Returns(request.Object); HomeController controller = new HomeC...

Is it possible to copy/clone HttpContext of a web request

What's the easiest way to clone current request's HttpContext instance? I'm developing an app in Asp.net MVC v1. I upgraded the regular PartialView capabilities to actually have sub-controllers that act very similar, but have their own context. When you use PartialViews you have to fill view data for the partial view in your main view's...

Context rewritepath problem with form C#

Hello i have a problem when i RewritePath in HttpContext, context.RewritePath(Utility.WebRoot + "List/Add.aspx", false); It work fine to rewrite the url: http://localhost/List/Add But when i hit the button it redirect me to http://localhost/List/Add.aspx Is there a good way to "stop" the redirection to the .aspx page and just leave...

How to ensure HTTPContext has value?

I am building a version of the MVC Storefront. I have two themes, one is the standard ui, and the other is the admin ui. I have some HTML Helper methods, which deliver .ascx files to the .aspx files just like the example, but without plug-ins. All the stuff works on the default theme, but none of it works in the admin theme. I always ge...

ASP.NET UrlReferrer

I have an ASP.Net application which generates short url for sharing. I want to track the url from where (source) click occured when it hits my asp.net page. I tried using Context.Request.UrlReferrer.AbsoluteUri but all I get from it is null. Any ideas? TIA ...

HttpContext.Current.User.Identity.Name is Empty

I have a silverlight application (using MVC) and when i'm building in visual studio, using Visual Studio Development center, there's no problem, the HttpContext.Current.User.Identity.Name has a Value But when i'm using the same project with IIS 7.5 (i'm using Windows 7), HttpContext.Current.User.Identity.Name stays empty Anyone who can...

How to obtain the HttpContext in Event Handler

Hello, I’m trying to obtain the HTTPContext within an Event Handler in a Document Library in MOSS, but all I have is a null value of the HTTPContext.Current, I do the same thing on a List and the HTTPContext is returned. There is a way to obtain the HTTPContext in Document Libraries to access the HTTPContext.Request method? Thanks for...

Access HttpContext inside WCF RequestInterceptor

I am using the WCF REST stater kit to build a plain xml over HTTP service. As part of this Im using a RequestInterceptor to do authentication. Inside of the RequestInterceptor I have access to a System.ServiceModel.Channels.RequestContext object from which i can get the request url, querystring params and other helpful things. What I can...

What is the difference between HttpContext.Current.Response and Page.Response?

I'm troubleshooting a caching issue on a set of secured pages and have realized that the Header needs to be modified for all Responses. As I put together a solution, I want to know the difference between HttpContext.Current.Response and Page.Response and when each object should be used in an app. Thanks. ...

Why mock HttpContext if it can be constructed?

Hi, I have always been faking/mocking/stubbing HttpContext somehow in ASP.NET (much easier in ASP.NET MVC/MonoRail). But I can see that HttpContext itself can be constructed easily, literally with couple of lines of code. var tw = new StringWriter(); var workerReq = new SimpleWorkerRequest("/webapp", @"c:\here\there\wwwroot", "pag...

cache problem in asp.net with c#

hi, I am using the fileuplaod control to upload the images. For this I used to stored it in the cache for 2 hours in byte format and show this image using the HttpContext in the .ashx file. For some Reason it is sometime saving in the cache and sometime not. I am using asp.net 2.0 and C# language. My code For Saving : //Name of the...

"System.Web.HttpContext cannot be serialized because it does not have a parameterless constructor."

I've created a web service that other sites can use to store errors in my database. They can then come to my site to view their errors, search through errors, filter errors, etc. However, I'm getting the following error for my web service: System.Web.HttpContext cannot be serialized because it does not have a parameterless construct...

HttpContext IP Problem

Hi, I have a problem when I use HttpContext.Current.Request.UserHostAddress, some times returns "192.168.0.17" (IPv4) and some times returns "fe80::99be:a05d:7938:1c30%8" (IPv6), calling from the same computer and navigator. What I do to return always IPv4? ...