This may not be the correct way to use controllers, but I did notice this problem and hadn't figured out a way to correct it.
public JsonResult SomeControllerAction() {
//The current method has the HttpContext just fine
bool currentIsNotNull = (this.HttpContext == null); //which is false
//creating a new instance of a...
I am wondering how the HttpContext is maintained given that the request-response nature of the web is essentially stateless.
Is an identifier being for the HttpContext object being sent as part of the __EVENTTarget / __EVENTARGUMENTS hidden fields so that the HttpRuntime class can create the HttpContext class by reading this section fro...
I've got a VB.NET module that reads from a resource file to display text in the correct language. Here's my problem - this code is shared between a web application and a non-web application, In the web application, I'm using System.Web.HttpContext to determine the user's preferred language, but now my Windows app won't even compile, beca...
I'm writing a component that I would like to be able to use in both MVC and WebForms web apps, but I'm not sure how to handle the differences between how HttpContext is handled.
My component involves a custom IHttpHandler (for WebForms) or a custom ActionResult (for MVC).
So I've got a few questions:
Is there a way to use an IHttpHan...
Hello Folks,
I was asking a related question but messed the title up and no-one would understand it. Since I am able now to ask the question more precisely, I decided to reformulate it in a new question and close the old one. Sorry for that.
So what I want to do is passing data (my custom user's nickname as stored in the db) to the Log...
I've got some RESTful services running in a pure WCF context (i.e. ASP.NET compatibility is not enabled, and thus there is no HttpContext.Current object available).
The URLs to the services are rewritten at the start of the request using an IHttpModule (which at that point does have an HttpContext and rewrites it using HttpContext.Curre...
I am doing some asynchronous work on a separate thread using:
ThreadPool.QueueUserWorkItem(...)
and in this separate thread, I need to call HttpContext.Current so that I can access:
HttpContext.Current.Cache
HttpContext.Current.Server
HttpContext.Current.Request
however, HttpContext.Current is null when I create this separate threa...
I am developing an application using asp.net 2.0 (C#), in which I am trying to implement the compression of my files, so that performance of my website will improve.
For that I have added a code in my Global.asax file to compress all requests (.aspx, .js, .css) But when I am running my application it works well for first time then the C...
I'm using FormsAuthentication for an ASP.NET site that has a master page that displays the current logged in user, Page.User.Identity.Name.
They can change their username in their settings, and when the do so, I update their cookie for them so they wont have to sign out/sign back in with a postback.
FormsAuthentication.SignOut();
Forms...
I've been using NHibernate for a while now and have found from time to time that if I try to request two pages simultaniously (or as close as I can) it will occasionally error. So I assumed that it was because my Session management was not thread safe.
I thought it was my class so I tried to use a different method from this blog post h...
I've got a textbox and a button on a form on default.aspx and in my DownloadHandler.ashx I am getting the value I need from HttpContext.Request.Form("txtURI"):
<asp:TextBox ID="txtURI"
AutoPostBack="true"
runat="server"></asp:TextBox>
<asp:Button ID="DownloadButton"...
I got a webapp that stores a config object in ApplicationState.
This object contains the connection string to the database among other things.
Sometimes i start a async thread to do a few longer running tasks, like sending emails and updating the database.
However since this thread don't have a HttpContext i can't get at the config obj...
I found this in some production login code I was looking at recently...
HttpContext.Current.Trace.Write(query + ": " + username + ", " + password));
...where query is a short SQL query to grab matching users. Does this have any sort of performance impact? I assume its very small.
Also, what is the purpose of this exact type of trac...
I'm running a web application that displays some debugging behavior if it's being run locally - quotes around resource strings, etc - and I'd like to demo the application on my laptop at a conference where I won't have internet access, so it has to be local.
The application uses HttpContext.Current.Request.IsLocal to determine if it's r...
Is there any way to get HttpContext.Current.Request.Url.Host and HttpContext.Current.Request.ApplicationPath in one call?
Something like "full application url"?
EDIT: Clarification - what I need is this the part within []:
http://[www.mysite.com/mywebapp]/Pages/Default.aspx
I ask simply out of curiosity.
EDIT 2: Thanks for all the...
I have an ASP.Net 3.0 SP1 app that uses Form Authentication.
While testing, I noticed that if I viewed a page that another user was viewing, the other users name would be displayed in the control on my master page. The Context.User.Identity is also for the other user.
If I switch to different page that no one else is viewing the Con...
I have a web app that currently uses the current HttpContext to store a LINQ Data Context. The context is persisted for the current request, on a per user basis, per Rick Strahl's blog:
string ocKey = "ocm_" + HttpContext.Current.GetHashCode().ToString("x")
Thread.CurrentContext.ContextID.ToString();
if (!HttpContext.Current.Items.C...
I'm new to Mocking frameworks and have started using RhinoMocks to assist with my MVC App Unit Testing.
I'm using Scott Hanselmanns MVC Mock Helper to assist in mocking the HttpContext.
I've succesfully (after some time) mocked some of what I need but have come unstuck when it comes to the Application property of the HttpContext.
In my...
I've got an object that handles in memory caching for my data access layer (DAL) and I need to persist it between threads. From what I've read the preferred method is to use httpcontext.item with code like so:
Shared Property DALList() As Dictionary(Of String, DAL)
Get
If Not Web.HttpContext.Current.Items.Contain...
User hits page spawn.aspx which then spawns a half-dozen threads, rendering pages all using
((System.Web.IHttpHandler)instance).ProcessRequest(reference to spawn's HTTPContext);
Don't worry about the fact that ASP.Net is seemingly sending the user 7 responses for 1 request, that part is handled and only one response gets sent.
The ...