Questions tagged [httpcontext]

HttpContext is a class from .NET Framework which provides information about an HTTP request.

HttpContext is a class from .NET Framework which provides information about an HTTP request.

1127 questions
0
votes
1 answer

Pulling string from xml

The xml is coming from a url and all I need is the pull the string "N0014E1" from it. I am not sure why this code is not working. I put a try block around it and I get a "Data root level is invalid" xml:
kevintdiy
  • 181
  • 2
  • 5
  • 13
0
votes
1 answer

Calling ScriptManager from a class

I'm trying to execute a javascript function from a C# class in an asp.net application. I'm using the ScriptManager. I have a class UpdateUI, which contains the following method: public static void RunScript() { try { if…
krafo
  • 183
  • 5
  • 20
0
votes
1 answer

I need help figuring out what _HttpContext.QueryString() does

I can't understand what some of my code is doing exactly. Here's what I have: model.People = _PersonProvider.GetListByIds(_HttpContext.QueryString()["people"]) I know that the model.People = (_HttpContext.QueryString()["people"] is supposed to…
DannyD
  • 2,732
  • 16
  • 51
  • 73
0
votes
1 answer

How to simulate a call to HttpContext.Cache["MyKey"] with Rhino Mocks?

Short version: How to get Rhino Mocks to simulate a call to HttpContext.Cache["MyKey"] and return expected data? Long version: I need to simulate a return value from the HttpContext.Cache with Rhino Mocks. I'm using the following code in the…
Guillaume
  • 1,782
  • 1
  • 25
  • 42
0
votes
0 answers

MVC 4 - Losing custom principal between beginrequest and endrequest

In my project (c#), we have an HttpModule that creates a custom Principal that we attach to the CurrentPrincipal. This is working in all of our MVC3 apps and in our classic ASP.Net apps. We have an AuthorizeAttribute override we use to secure our…
richb01
  • 1,097
  • 2
  • 13
  • 25
0
votes
1 answer

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…
Alpinfish
  • 3
  • 4
0
votes
1 answer

Pass HttpContext.Request parameter around or use static instance?

In an MVC3 application, I need to construct a domain object from values contained in the incoming Http Request. The logic is sufficiently complex that I have created a factory class with the responsibility of creating my domain object. My question…
Nick
  • 6,366
  • 5
  • 43
  • 62
0
votes
1 answer

Current user identity in ObjectContext.SavingChanges

I am using ObjectContext.SavingChanges event to update CreatedDate/UpdatedDate columns based on the object state like this partial void OnContextCreated() { //Extension of the Command Timeout to avoid processing problems. CommandTimeout = 600;…
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105
0
votes
1 answer

How can I use the HttpContext.Current.User.Identity to provide authentication to my SmtpClient.Credentials?

I have a weird situation. In my website, I impersonate a lab account for access to a database, but for the front-end, I allow Windows authentication. So that means HttpContext.Current.User.Identity.Name.Split('\')1 gives me the name of the user…
Freakishly
  • 1,533
  • 5
  • 32
  • 61
0
votes
2 answers

Context rewritepath problem with form C#

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…
user105496
0
votes
2 answers

HTTP Context in static class

As I know the static method of the static class is shared to all the user in a web application. How does HttpContext.Current.Session["Key"] work in a static classes. Since the session is created for every user. An example below return the user name…
शेखर
  • 17,412
  • 13
  • 61
  • 117
0
votes
1 answer

Is HttpContext.ApplicationInstance.Context unique for each request?

In MVC3, I want to access the HttpContext from a Controller (not the HttpContextBase returned by the HttpContext property). Several articles (and StackOverflow answers) suggest using HttpContext.ApplicationInstance.Context. I've tried it, and it…
0
votes
2 answers

Save object in Session on a ashx handler and get the object in another ashx handler. How?

I have two handlers. In Authentication.ashx Handler i save a object on session like this: HttpContext.Current.Session["ConnectionUserSession"] = userCache; Then, i have another Handler, Send.ashx and i want to get the object saved in…
mrodriguez
  • 91
  • 12
0
votes
2 answers

Get HttpContext from JQuery AJAX GET

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…
Nick
  • 19,198
  • 51
  • 185
  • 312
0
votes
2 answers

DbContext per HTTP Request But Avoid Dependency on HttpContext in Data Layer

I've been thinking of how I could use one instance of a DbContext per HttpRequest in a layered application. One of the solutions I came up with would be to create an HttpModule that would initialize an instance of the context in…
Kassem
  • 8,116
  • 17
  • 75
  • 116