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

Weird HttpContext.User.Identity issue

I have an MVC 3 project which authenticates users by Forms Authentication. To access user's different information when needed after authentication I have implemented a simple class: public class ComplexUserData { public static string…
Kadir.K
  • 366
  • 4
  • 17
0
votes
0 answers

Want to access Username in current HttpContext

I want to access the Username of current Logged in User into Web.Config so that I can use it with Log4Net. I have made a new file as:: namespace VZDev.Helpers { class HttpContextUserPatternConverter : PatternLayoutConverter { …
user2624970
  • 23
  • 1
  • 1
  • 4
0
votes
1 answer

Access appSettings in web.config from Thread in Class Library project

Can I able to access appSettings section in my ASP.NET web.config file from a method in another referenced Class Library project when it is called as a new Thread? I'm accessing the setting through a property as private static string TempXmlFolder …
Sen Jacob
  • 3,384
  • 3
  • 35
  • 61
0
votes
1 answer

httpcontext.current.server.mappath and unit testing

I use asp.net mvc3/razor with dbfirst model. I send a confirmation email after registration that is in a xml format. I need to read this xml file while unit testing, I get null reference error as httpcontext.current is null.I tried to mock it, but…
gs11111
  • 649
  • 2
  • 17
  • 49
0
votes
2 answers

SqlConnection and HttpContext

Could I store a SqlConnection in the HttpContext? I mean, how can I share a single SqlConnection across multiple classes? In my project every class inherits a base abstract class that open and close connection. This class recognizes if a…
user2336491
  • 47
  • 1
  • 2
  • 4
0
votes
0 answers

Not able to generate the read only work sheets from a response stream

I am not able to make exported excel file as read only. Below is my code to export excel file. private void ExporttoExcel(DataTable table) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearContent(); …
Ubaid Ashraf
  • 1,049
  • 5
  • 15
  • 43
0
votes
1 answer

IHttp Generic Handler (.ashx) for Images cache validator

I have IHttp Generic Handler (.ashx) for images and I have sent cache expire time as 7 days but in Google page insight it says I should add cache validator. following is my code. Please refer me something. public void ProcessRequest(HttpContext…
0
votes
1 answer

Cookie's value is doubled without any reason

I've got an problem with Cookie. That's the code: NameValueCollection ncook = new NameValueCollection(); ncook = HttpContext.Current.Request.Cookies["history"].Values - in that line What is in my cookie:…
0
votes
2 answers

Creating an HttpContext in MVC/StructureMap project running as a non-web app

How can I create an instance of HttContext and register it in StructureMap config? I have an MVC3 web project using StructureMap with, I think, a typical setup where the controllers call repository class and the repo classes are responsible for…
getit
  • 623
  • 2
  • 8
  • 30
0
votes
1 answer

Output word document as docx extension working only in firefox

I am using following code to output html string into word document with .docx extension [not .doc] private void ExportBodyAsDoc(string strBody) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType =…
Saad
  • 1,312
  • 5
  • 17
  • 40
0
votes
0 answers

How to implement caching in a WebApplication .NET?

I'm working on a WebApplication, and I need to implement a cache mechanism. Basically I need to call a Webservice and update the cache with the results. My first attempt was to do that with a timer. Created the class with methods to initialize the…
0
votes
1 answer

Asp.net C# Capture Output to String

I'm writing because I'm stuck on a problem, I have code that currently writes the output of an aspx page to a word document. This code works perfectly fine. However I need to actually save that file to the server. Here is the code that is…
Joe Stellato
  • 558
  • 9
  • 31
0
votes
1 answer

WCF Restful Service static variable

I currently have 2 static dictionaries in a wcf restful service. These both hold look up data that's not worth putting in a database. Will these stay in memory until the application restarts or should I put them in HttpContext.Current.Application?
Shawn
  • 2,356
  • 6
  • 48
  • 82
0
votes
1 answer

Multiple identical forms on a page in asp.net. How do I get variables?

I'm having trouble figuring this out. I can't explain it that well, so here some html/asp first: <%for(int i=0; i
DerpyNerd
  • 4,743
  • 7
  • 41
  • 92
0
votes
0 answers

Why does HttpContext.Current.Request.InputStream always have length 0?

Sorry, but I don't have a better description of my problem. I'll edit the post if I discover something. I am building an F#-C# MVC4 application (in Windows 8, using Visual Studio 2012 Express for Web). Everything was working without a problem. I…
Shredderroy
  • 2,860
  • 2
  • 29
  • 53