C# - How To Get The Physical Location Of Web Application Without Using HttpContext.Current

Jun 11, 2010

I've found myself having a requirement to configure log4net based on a file relative to the physical location of the running ASP.NET web application. We like to start the logger as early as possible, so Application_Start seems a proper place. In IIS6, this works fine and has been running for ages, but now we moved to IIS7 and this won't work anymore:

string absolutePath = HttpContext.Current.Request.PhysicalApplicationPath;

because the HttpContext.Current is not available in many global.asax (Application, Session) events. This is old news, we all know it raises the now infamous Request is not available in this context error. We don't want to move back to Classic Mode.

Now, the question is simple: without using HttpContext, is it possible to find the physical location of the currently running web application instance?

View 2 Replies


Similar Messages:

C# - How To Access HttpContext.Current.Application

Jun 7, 2010

i have problem accessing HttpContext.Current.Application From global.asax its seems to be null every time i try to access it. How can i to this?

HttpContext.Current.Application.Lock();
HttpContext.Current.Application["Actions"] = "hello";
HttpContext.Current.Application.UnLock();

View 2 Replies

HttpContext.Current.Application During Load Balancing

Oct 13, 2010

I wanted to understand the behavior of HttpContext.Current.Application during the load balancing. I have read that session can be stored in disk hence can be retrieved from different servers. Is this true for HttpContext.Current.Application also. Does the keydata stored in one machine is accessible in other different machine too?

View 1 Replies

C# - Determine The Physical Path Of A File Without An HttpContext?

Aug 23, 2010

I have some processes that run without an HttpContext in an ASP.NET MVC web application. This process needs to be able to determine the physical path to the Contents directory of the application for reading/writing data. But, since it is without an HttpContext, I don't get to use fancy things like Server.MapPath and such.

View 2 Replies

Configuration :: Run Different Website From Same Physical Location?

Dec 22, 2010

I have a website say www.abc.com I am giving the users there own mini site with the URLwww.abc.com/website/home.aspx?UID=1

This URL will access to my Home.aspx page located in website folder and display the user information based on UID

I want to register each user with their own domain and redirect the functionality to mywww.abc.com/website/home.aspx?UID=1 page.

For example let's say when user type www.user.com user the site will be redirected to mywww.abc.com/website/home.aspx?UID=1 page but the URL of web browser will not change, user can still seewww.user.com on his web browser.

If User click about us link i.e. www.user.com/aboutus/ the site will be redirected towww.abc.com/website/aboutus.aspx?UID=1 page but the URL of web browser will not change.

I am using IIS 6 and ASP.net 2.0.

View 4 Replies

Web Forms :: Run Different Website On Same Physical Location

Dec 22, 2010

I have a website say [URL] I am giving the users there own mini site with the [URL] This URL will access to my Home.aspx page located in website folder and display the user information based on UID. I want to register each user with their own domain and redirect the functionality to my [URL] For example let's say when user type [URL] user the site will be redirected to my [URL] page but the URL of web browser will not change, user can still see [URL] on his web browser. If User click about us link i.e. [URL] the site will be redirected to [URL] page but the URL of web browser will not change. I am using IIS 6 and ASP.net 2.0.

View 2 Replies

Non Physical Location Authorization In IIS6?

Aug 30, 2010

I'm running an Asp.NET MVC 2 app under IIS 6.All pages are behind Windows Integrated Authentication except for some pages that accepts anonymous access.We setup these pages in the web.config with the location element like this

<location path="MyPath/ToThePage">
<system.web>
<authorization>

[code]...

this is an Asp.NET MVC app, the path indicated in the path attribute points to an action method not a physical location.When this was running under IIS 7 integrated mode it was working fine. But when we switched to IIS 6 we get the login prompt even with the pages that are set to accept anonymous users.ow to make IIS 6 authorize anonymous access to non physical paths ?

View 1 Replies

How To Determine The Physical Location Of Website

Jul 30, 2010

I've set up IIS7 on my home computer and have written a very basic ASP.NET website to be deployed on this webserver. Everything works great. How do I determine programmatically the physical path (for instance, "C:inetpub_MyWebsite") of the website? I need to write an XML file to the website's root folder dynamically and therefore need to know the folder's physical location.

View 3 Replies

Social Networking :: Get Distance From Current Location To Destination Location Google Map

Mar 26, 2016

URL....This link shows a demo that let user to put origin and destination then get direction. I want to know how to add a option which is let user to use their current location as origin location (Location from).

View 1 Replies

Finding Difference System.web.httpcontext.current.application And System.Configuration.Appsettings?

Jan 22, 2010

Can anyone tell me the differnce between

System.web.httpcontext.current.application["tag"]

or

System.Configuration.Appsettings["tag"]

View 2 Replies

Access The Current Thread's Context Using HttpContext.Current?

Mar 11, 2010

I have a static class with serveral static methods. In these methods, I'm trying to access the current thread's context using HttpContext.Current. For example:

var userName = HttpContext.Current.User.Identity.Name;

However, when I do that, I receive a NullReferenceException, the infamous "Object reference not set to an instance of an object."

View 3 Replies

Web Forms :: User Can Download Files From Database Instead Of Physical Location On The Web Server?

May 3, 2010

we have some files in our web app which saved in database.

how user can download files from our web site which exists in database (and not physically saved) ?

View 3 Replies

Difference Between ControllerContext.HttpContext.Session And HttpContext.Current.Session

Nov 23, 2010

i'm using an example in which i can fake the session.It's for use in a unittest of a mvc controller.In the test i create a controller and then i do this:

FakeHttpContext httpctx = new FakeHttpContext(null,null,null,null,mSessionItems );
ControllerContext ctx2 = new ControllerContext(httpctx,new RouteData(), target);

here mSessionItems is my session and target is my instance of a controller,and indeed, when i'm in a controller reading this.ControllerContext.HttpContext.Session, i have a session, great!but.... i also read the session outside the controller, and there i use HttpContext.Current.Session, and that is null (or actualy, the HttpContext.Current is null).

View 1 Replies

How To HttpContext.Current Work?

Aug 5, 2010

I'm wondering how HttpContext.Current gets assigned a unique instance for every request considering it's a static object?

View 2 Replies

Application_PreRequestHandlerExecute: Null HttpContext.Current?

Feb 5, 2010

Is it safe to always assume that HttpContext.Current will be non-null in Application_PreRequestHandlerExecute?

EDIT: Assuming ASP.NET webforms (not MVC).

View 2 Replies

HttpContext.Current / Cache Available To All Sessions

May 4, 2010

As per title. I want to be able to save some data in a cache object but this object must be available to all users/sessions and can expire.What is the best method to achieve this in a asp.net web app?

View 2 Replies

HttpContext.Current.Session Is Null

Aug 20, 2010

I am getting HttpContext.Current.Session is null.Will this be a problem if we have application hosted in web farm.

View 1 Replies

How To Use Server.MapPath When HTTPContext .Current Is Nothing

Jan 20, 2011

I have some code that works fine when I need to delete some image files from a directory on my web server:

Dim ImageURL As String = dsImages.Tables(0).Rows(iImgRow).Item("ImageURL")
Dim physicalName = Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdid, iImgID)

.but I am running into a problem when a maintenance task running in a separate thread at set intervals determines that files like the above need to be deleted:

Dim ImageURL As String = dsImage.Tables(0).Rows(i - 1).Item("ImageURL")
Dim iImgID As Integer = dsImage.Tables(0).Rows(i - 1).Item("ImageId")
Dim physicalName As String = HttpContext.Current.Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdID, iImgID)

In this latter case, HttpContext.Current.Server.MapPath(ImageURL) has a value of Nothing.Is there a way to get the full path for this case?

View 1 Replies

Why Does HttpContext.Current Need To Used Within A Class, But Not A Method

Feb 12, 2011

For instance if I'm inside the Page_Load method and I want to get query string data I just do this:

public partial class Product_Detail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
[code].....

View 4 Replies

How To Access Cache When No HttpContext.Current Is Available

Dec 15, 2010

During Application_End() in Global.aspx, HttpContext.Current is null. I still want to be able to access cache - it's in memory, so want to see if I can reference it somehow to save bits to disk.

Question - is there a way to reference cache in memory somehow when HttpContext.Current is null?

Perhaps I could create a global static variable that would store pointer to cache that I could update on HTTP requests (pseudo: "static <pointer X>" = HttpRequest.Current) and retrieve a reference to cache through that pointer in Application_End()?

Is there a better way to access Cache in memory when there is no Http Request is made?

View 3 Replies

HttpContext.Current.User.Identity.Name With And Without Www?

Oct 20, 2010

am writing a web service in vb.net/asp.net 2, that needs user's name. It works fine when the url request is "www.mysite.com" but if any one has logged-in using "mysite.com" without a "www" and goes to the page that calls my web service, The HttpContext.Current.User.Identity.Name gives null. How can I resolve this problem?

View 2 Replies

Where Does Httpcontext.current.server.mappath Start

Jan 15, 2010

Where does httpcontext.current.server.mappath start?

I don't get it... it doesn't return a path.

My webservice is ran when I debug my application :S.

View 4 Replies

C# - Caching Through HttpContext.Current.Cache Or Just A Static?

Mar 28, 2011

Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular expression object to prevent creation of it on every request.

Now my question... what is better: use the HttpContext.Current.Cache to store the instantiated object or to use a private static Regex in my module?I'm looking forward to the reasons why. Just to clarify: the regex will never change and thus always be the same thing.

View 3 Replies

How To Reference A Scriptmanager From HttpContext.Current.CurrentHandler

Mar 28, 2010

I reference the current page in a class with

Page page = HttpContext.Current.CurrentHandler as Page;

I know need to reference ScriptManager1. What the syntax ?

View 2 Replies

How To Get Session Data With Out Having HttpContext.Current, By SessionID

May 5, 2010

I am searching to find a way to read and write on session data but with out having the HttpContext.Current.Why I won to do that ?, because I wish to make some action with the user Session after the page have been close and unloaded. For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext.Current is not exist any more.

So is there a way to read Session Data knowing just the session id.I store my session inside an sql server, and I see them... its there on table ASPStateTempSessions . How can I read them "offline" and manipulate them ?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved