Tuesday, March 13, 2012

Server.MapPath

I am trying to set up the "path" for were my Access Database is on my
Webhost provideer. When I set up my FTP account, it indicated that my
physical path was "E:\www.MyWebsite.com".

When I asked my webhost if I could use this as my physical address, they
indicated that I should create a directory under the root and place my
access database there and the use the "Server.MetPath(string)" to retrieve
the path.

My question is what value do I place in the "String" portion of the method.
I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
correct?

If that is correct, then how will I be able to modify my code to work on my
test machine and work on the production box without changes? I would guess
that I would use "localhost" or my IP address, but that would not be the
same for when I move the code to the production box. I guess I could place
the value in the web.config file, but is there a better way to do this?

Thanks in advance for your assistance!!!!!!!!!!!!Hi Jim,
You will need to use Server.MapPath not Server.MetPath
In your website say http://www.MyWebsite.com/MyDataFolder
,MyDataFolder is the virtual path.
To translate this virtual path into the actual physical path you need to use
Server.MapPath.
It will be like : Server.MapPath("MyDataFolder") which will give you
the physical path.
The output of this will be like E:\www.MyWebsite.com\MyDataFolder which is
the actual physical path.

Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com

"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns9498E011611CBJimHeaveyhotmailcom@.207.46.24 8.16...
> I am trying to set up the "path" for were my Access Database is on my
> Webhost provideer. When I set up my FTP account, it indicated that my
> physical path was "E:\www.MyWebsite.com".
> When I asked my webhost if I could use this as my physical address, they
> indicated that I should create a directory under the root and place my
> access database there and the use the "Server.MetPath(string)" to retrieve
> the path.
> My question is what value do I place in the "String" portion of the
method.
> I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
> correct?
> If that is correct, then how will I be able to modify my code to work on
my
> test machine and work on the production box without changes? I would
guess
> that I would use "localhost" or my IP address, but that would not be the
> same for when I move the code to the production box. I guess I could
place
> the value in the web.config file, but is there a better way to do this?
> Thanks in advance for your assistance!!!!!!!!!!!!
You probably just want Server.MapPath("/MyDataFolder"). Since the string
doesn't contain the host name, there is no need to change it for your test
server.

"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns9498E011611CBJimHeaveyhotmailcom@.207.46.24 8.16...
> I am trying to set up the "path" for were my Access Database is on my
> Webhost provideer. When I set up my FTP account, it indicated that my
> physical path was "E:\www.MyWebsite.com".
> When I asked my webhost if I could use this as my physical address, they
> indicated that I should create a directory under the root and place my
> access database there and the use the "Server.MetPath(string)" to retrieve
> the path.
> My question is what value do I place in the "String" portion of the
method.
> I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
> correct?
> If that is correct, then how will I be able to modify my code to work on
my
> test machine and work on the production box without changes? I would
guess
> that I would use "localhost" or my IP address, but that would not be the
> same for when I move the code to the production box. I guess I could
place
> the value in the web.config file, but is there a better way to do this?
> Thanks in advance for your assistance!!!!!!!!!!!!

0 comments:

Post a Comment