|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Server.MapPath from a vb classI've used this a bit from codebehind with no problems, but now I'm
having some issues when I try to use it from a vb class in my application. Looking in help, it looks like I need to do something like this: dim Server As HttpServerUtility Dim path As String = Server.MapPath("myfile.txt") ---- But any time I use that Server variable I get a null refrence exception. What am I doing wrong? Thanks! Matt You have to use httpcontext to get the server object when you are on a
class. Hope this helps snt http://www.flexoweb.com tint wrote:
> You have to use httpcontext to get the server object when you are on a Yep. HttpContext.Current to be exact. Thanks!> class. Hope this helps > > snt > http://www.flexoweb.com > Matt Great, I had the same problem, HttpContext.Current.Server.MapPath works
perfect!
--
kris kilowatt
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
Don't write "dim Server As HttpServerUtility"
just Dim path As String = Server.MapPath("myfile.txt") Ibrahim ULUDAG www.ibrahimuludag.com Show quoteHide quote "MattB" <somedud***@yahoo.com> wrote in message news:3gu0paFedcjhU1@individual.net... > I've used this a bit from codebehind with no problems, but now I'm having > some issues when I try to use it from a vb class in my application. > Looking in help, it looks like I need to do something like this: > > dim Server As HttpServerUtility > Dim path As String = Server.MapPath("myfile.txt") > > ---- > > But any time I use that Server variable I get a null refrence exception. > What am I doing wrong? Thanks! > > Matt
Other interesting topics
Authentication mode in web.config causing crash.
Dynamically position custom control .ascx Message Box in ASP Options for generic full-text search without using database-specific full-text engine? Firefox Validation Issue - not the standard document.[all] problem! Dataview returns 0 rows Newbie on Session State Unable to map the debug start page URL to a machine name User Controls in 2.0 Disabling Validator |
|||||||||||||||||||||||