473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

ResolveUrl in a static helper method

When I want some app resources I usually write something like:
MapPath(ResolveUrl("~/App_Data/MyResource"))

How could I do the same thing in a static helper method?
I mean MapPath & ResolveUrl are instance method of Page, so a static method
can't use them...

--
I have taken a vow of poverty. If you want to really piss me off, send me
money.
Jan 11 '06 #1
4 4483
HttpContext.Current.Server.MapPath("~/App_Data")

seems to do the trick!!!

"Lloyd Dupont" <net.galador@ld> wrote in message
news:e2*************@TK2MSFTNGP12.phx.gbl...
When I want some app resources I usually write something like:
MapPath(ResolveUrl("~/App_Data/MyResource"))

How could I do the same thing in a static helper method?
I mean MapPath & ResolveUrl are instance method of Page, so a static
method can't use them...

--
I have taken a vow of poverty. If you want to really piss me off, send me
money.

Jan 11 '06 #2
Server and url seem to relate but don't.
Server seems to be obtainable at all time, resolveurl is context related.

Server:
Dim p As New System.Web.UI.Page
p.server.mappath(...
p.dispose
"Lloyd Dupont" <net.galador@ld> schreef in bericht
news:Ok**************@tk2msftngp13.phx.gbl...
HttpContext.Current.Server.MapPath("~/App_Data")

seems to do the trick!!!

"Lloyd Dupont" <net.galador@ld> wrote in message
news:e2*************@TK2MSFTNGP12.phx.gbl...
When I want some app resources I usually write something like:
MapPath(ResolveUrl("~/App_Data/MyResource"))

How could I do the same thing in a static helper method?
I mean MapPath & ResolveUrl are instance method of Page, so a static
method can't use them...

--
I have taken a vow of poverty. If you want to really piss me off, send me
money.


Jan 11 '06 #3

Also see HostingEnvironment in the System.Web.Hosting namespace. At some
point you'll probably want to take a look at VirtualPathUtility from
System.Web too.

Luke

Lloyd Dupont wrote:
HttpContext.Current.Server.MapPath("~/App_Data")

seems to do the trick!!!

"Lloyd Dupont" <net.galador@ld> wrote in message
news:e2*************@TK2MSFTNGP12.phx.gbl...
When I want some app resources I usually write something like:
MapPath(ResolveUrl("~/App_Data/MyResource"))

How could I do the same thing in a static helper method?
I mean MapPath & ResolveUrl are instance method of Page, so a static
method can't use them...

--
I have taken a vow of poverty. If you want to really piss me off, send me
money.


Jan 11 '06 #4
interesting...

"Luke Dalessandro" <us****@luked.net> wrote in message
news:zW****************@news01.roc.ny...

Also see HostingEnvironment in the System.Web.Hosting namespace. At some
point you'll probably want to take a look at VirtualPathUtility from
System.Web too.

Luke

Lloyd Dupont wrote:
HttpContext.Current.Server.MapPath("~/App_Data")

seems to do the trick!!!

"Lloyd Dupont" <net.galador@ld> wrote in message
news:e2*************@TK2MSFTNGP12.phx.gbl...
When I want some app resources I usually write something like:
MapPath(ResolveUrl("~/App_Data/MyResource"))

How could I do the same thing in a static helper method?
I mean MapPath & ResolveUrl are instance method of Page, so a static
method can't use them...

--
I have taken a vow of poverty. If you want to really piss me off, send
me money.


Jan 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew Parker | last post by:
Hi, I'm having a syntax problem and hours of googling has yet to reveal a solution. I'm writing a class that contains only public static methods. It's a class of useful misc. functions that don't...
4
by: Jonathan Roewen | last post by:
Hi I've got loading assemblies dynamically done (wasn't too difficult). Now I want to lookup a static function in the loaded assembly, and if found, return it somehow, and call it from my app. So...
3
by: Dave | last post by:
Hi everyone, Is it possible, using an Attribute or by some other means, to notify the C# Compiler to serialize all static field's that have initializers before code in an explicit static...
10
by: Marek | last post by:
Hi, I am analyzing Duwamish7 source code boundled with Visual Studio .NET 2003. Could anoybody explain why the Monitor.Enter and Monitor.Exit block is used inside a static constructor? The code...
8
by: Fernando Lopes | last post by:
Hi there! Someone has some code sample about when is recommend use a statis method? I know this methos don't want to be initialized and all but I want to know when I need to use it. Tks....
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
4
by: SandyIsCool | last post by:
Hi, Can any one let me know what is difference between Server.mappath and Page.resolveURL and what are the situations we use them. Thanks, Sandy
2
by: SandyIsCool | last post by:
Hi I used the below code for an image button image1.imageurl="~/images/image1.jpg"; image1.imageurl=Page.ResolveUrl("~/images/image1.jpg"); Both statements work fine..
6
by: =?Utf-8?B?TWF0dA==?= | last post by:
I'm having a problem with a static class constructor being called twice. I have the static class MasterTaskList which uses a BackgroundWorker to execute multiple methods on a separate thread. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.