First off, I wish context based storage was consistent across the framework!
With that said, I'm looking for an elegant solution to make these properties safe across ASP.NET, WCF and any other multithreaded .NET code. The properties are located in some low-level tracing helpers (these are exposed via methods if you're wondering why they...
I have
FormsAuthentication.SetAuthCookie("someName", True)
as part of my custom login sequence. Later, I have some page only allowing a specific role:
<location path="myPage.aspx">
<system.web>
<authorization>
<allow roles="SomeRole"/>
<deny users="*"/>
</authorization>
</system.web>
...
I want to get the working folder of a WCF application. How can I get it?
If I try HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath) I get a null reference exception (the Http.Current object is null).
[Updated]
What I meant with the working folder was the folder where my WCF service is running. If I set a...
So since System.Web & HttpContext isn't available in Silverlight is there a way to do HtmlDecode & HtmlEncode inside a Silverlight app without some horrendous Regex?
...
I have a very strange behavior with Request.Form.
Here are two IIS 7 servers running the same ASP.NET application. On the first instance it's all ok. But the second one have very slow performance.
Profiler showed that this line:
context.Request.Form["id"]
takes more than 130 ms each time!
Profiler log:
0,60% get_Form - 4536 ms - 6...
Hello,
Currently I have an ActionFilter that gets the current users name from HttpContext and passes it into the action which uses it on a service method. eg:
Service.DoSomething(userName);
I now have a reason to do this not at the action level but the controller constructor level. Currently I'm using structure map to create contro...
I am sending a file to the user using a HttpHandler. On all browsers, after viewing/downloading the file at least once, the browser/application on subsequent views/downloads hangs. Here is the code:
private void TransmitFile(HttpContext context, string filePath, string downloadName, bool forceDownload)
{
if (File.Exists(...
This is driving me mad. I've implemented the Web.Routing on a Web Forms application. The application works fine and then inexplicably (at least at the moment) the following error message is thrown:
Object reference not set to an
instance of an object. at
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase
httpContex...
I separated all direct session interaction into a separate class and made it static, because I didn't want to create a new object several times. However, i wish to make sure that there are not concurrency issues or other wonky suprises.
Here is the code:
public static class HttpHelper
{
public static string Get(string key)
{
...
I have a 'context' object that ties itself to HttpContext.Items via a static Current property. This object can be used directly, through expression builders and controls, all being part of the same library.
The issue I'm coming across is that I want to dispose of it's managed resources (WCF clients) when a request ends without using an...
Issue
I am using Castle Windsor as an IoC container in a Castle Monorail project. I would like to inject the current instance of IRailsEngineContext into an object being resolved from the container in a controller.
Context
The object I would like inject the rails context into would be used to wrap the session object for the purpose...
Context: .Net 3.5, C#
I'd like to have caching mechanism in my Console application.
Instead of re-inventing the wheel, I'd like to use System.Web.Caching.Cache (and that's a final decision, I can't use other caching framework, don't ask why).
However, it looks like System.Web.Caching.Cache is supposed to run only in a valid HTTP context....
Hi I use a custom MembershipProvider.
I want to know the current username during an application scenario, but when I try accessing HttpContext.Current.User.Identity.Name it always returns string.Empty.
if (Membership.ValidateUser(tbUsername.Text, tbPassword.Text))
{
FormsAuthentication.SetAuthCookie(tbUsername.Text, true);
bool...
Is there a way to look through the cache for all objects in the cache? I'm dynamically creating objects and I need to periodically go through the list to purge out objects I'm no longer using.
...
Hi, I have a class in my asp.net proj, I would like to get access GetGlobalResourceObject (that page exposes), from anywhere in the site, possible?
In other words I wanna access the global resources from a class that is not a page I don't care how.
...
I know there is a very similar question here but I was hoping to get a better explination. Why would I ever use HttpContext.Cache instead of HttpRuntime.Cache if the HttpContext really uses the HttpRuntime.Cache behind the scenes?
In the article Simulate a Windows Service using ASP.NET to run scheduled jobs Omar uses the HttpContext to ...
I have the following requirement.
public void GetSubSite(SPWeb site)
{
site.AllowUnsafeUpdates = true;
SPList destinationList = site.Lists[TASKS];
SPWebCollection subSitesCollection = site.Webs;
foreach (SPWeb subSite in subSitesCollection)
{
//.....
Now I want to display the destinationList as a web part,...
I'm implimenting my own ApplicationContext class that uses the singleton pattern. I want to store my instance of it in HttpContext.Items, since it is accessible in all parts of the request. I've been reading about using HttpContext with ASP.NET MVC and one of the major pains is that it introduces testing complexity. I've tried doing re...
I have a WCF service that does some document conversions and returns the document to the caller. When developing locally on my local dev server, the service is hosted on ASP.NET Development server, a console application invokes the operation and executes within seconds.
When I host the service in IIS via a .svc file, two of the documen...
Here is My Code To Log In
var expire = DateTime.Now.AddDays(7);
// Create a new ticket used for authentication
var ticket = new FormsAuthenticationTicket(
1, // Ticket version
username, // Username to be associated with this ticket
DateTime.Now, // Date/time issued
expire, // Date/time to...