Server.MapPath 12-04-09

What is syntax for Server.MapPath when I am in a class module? Thanks.

David 


0
David
12/4/2009 3:01:21 PM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

4 Replies
661 Views

Similar Articles

[PageSpeed] 45

Try:

HttpContext.Current.Server.MapPath("path");



Leszek

"David C" <dlchase@lifetimeinc.com> wrote in message 
news:uEhqhLPdKHA.4112@TK2MSFTNGP06.phx.gbl...
> What is syntax for Server.MapPath when I am in a class module? Thanks.
>
> David
> 


0
Leszek
12/4/2009 3:55:19 PM
"David C" <dlchase@lifetimeinc.com> wrote in news:uEhqhLPdKHA.4112
@TK2MSFTNGP06.phx.gbl:

> What is syntax for Server.MapPath when I am in a class module? Thanks.

Leszek has the answer. You also have to reference the web assembly to 
use it.

NOTE: If this class library is not a UI library, I would not do it this 
way. You are tightly coupling the library to the an ASP.NET UI, which 
means you cannot easily refactor the application to any other type of 
UI. If this is a UI only library, then there is no issue, of course.

Peace and Grace,

-- 
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
|      Think outside the box!             |
*******************************************
0
Gregory
12/4/2009 7:17:55 PM
"Leszek" <spam@no-spam.pls> wrote in news:uIWoUoPdKHA.4780
@TK2MSFTNGP04.phx.gbl:

> HttpContext.Current.Server.MapPath("path");

The only potential issue I have with this is if the class library is a 
business layer (middle tier) assembly. This code will tightly couple the 
library to an ASP.NET UI.

Peace and Grace,

-- 
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
|      Think outside the box!             |
*******************************************
0
Gregory
12/4/2009 7:18:49 PM
You're sure right Gregory. Using HttpContext tights the code to the ASP.NET 
layer (we need to be in the HTTP Context in order to use the HttpContext :).
I understand that David's question referred to a class within the App_Code 
folder (David said: "a class module") which is a part of the web 
application.

If the "class module" means a class defined in an external assembly 
referenced by David's ASP.NET application it also would have access to the 
HttpContext. It is common to develop a set of WebControls as an additional 
assembly. These controls would have access to the application's HttpContext.

The caveat of using HttpContext is pointed by Gregory:
"you cannot easily refactor the application to any other type of UI"
than ASP.NET

Cheers,
Leszek

"Gregory A. Beamer" <NoSpamMgbworld@comcast.netNoSpamM> wrote in message 
news:Xns9CD786FAE7B67gbworld@207.46.248.16...
> "David C" <dlchase@lifetimeinc.com> wrote in news:uEhqhLPdKHA.4112
> @TK2MSFTNGP06.phx.gbl:
>
>> What is syntax for Server.MapPath when I am in a class module? Thanks.
>
> Leszek has the answer. You also have to reference the web assembly to
> use it.
>
> NOTE: If this class library is not a UI library, I would not do it this
> way. You are tightly coupling the library to the an ASP.NET UI, which
> means you cannot easily refactor the application to any other type of
> UI. If this is a UI only library, then there is no issue, of course.
>
> Peace and Grace,
>
> -- 
> Gregory A. Beamer (MVP)
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> |      Think outside the box!             |
> ******************************************* 


0
Leszek
12/4/2009 8:51:29 PM
Reply:

Similar Artilces:

NO DEFAULT SMTP SERVER..
Hello, I had a problem with exadmin.dll, unregistered it, copied new one and registered it and now the default smtp server is gone under SMTP in my systems manager but everything still works.... HELP where is it ? and how can i get it back ? tnnx. Philippe ...

Root Element is Missing 12-21-04
When going to Advanced Find View I receive the following detailed error message. The root element is missing. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Xml.XmlException: The root element is missing. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception st...

Hyperlinks #12
Hi I have a spreadsheet that contains many hyperlinks to other excel and word files. When I have to provide a client with a copy of this file and all the links, I have simply burned a CD with the file and links. However, when the client opens it, the file wont open. The original files are on our server and when the client tries to open them, the path starts looking for the server name. Is there anyway to insert hyperlinks without specifying path? Please help. Thanking you in advance. ...

Upgrading from server 2000 to server 2008R2?
We would like to upgrade our servers to Windows server 2008 R2. Currently we have two Windows 2000 (SP 4) domain controllers, we want to replace the Forest Root Domain box with new hardware & upgrade the other DC to server 2008 R2. I understand it's not possible to upgrade from 2000 straight to 2008 but is server 2003 still available to ugrade to in between? I'm also not sure of what the implications of retiring the Forest Root Domain box would be? Would the best plan be to add the new 2008 server (domain function & forest function level: 2000); upgrade the se...

12 month planner
I have been trying to create a 12 month planner. I would like the two sided kind that I can bind. It is possible to use a planner as a guide, but time is a problem. I would like to just use a template. Thanks There are planners here, probably not what you are wanting. http://office.microsoft.com/en-us/templates/results.aspx?qu=planner&av=TPL000 What dimensions are you using? You probably could get a reasonably priced planner at a big box store. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Autumnm" <Autumnm@dis...

Can Recovery Storage Groups be used if original server gone?
We had an Exchange server die on us a few months back due to hardware issues. All accounts were moved to another box and that one was flattened and taken out of the Exchange org. It was replaced by new hardware that does NOT have the storage groups or databases that the old one did. We have a request to recover data from an info store back up prior to the events above and are running into problems with our backup vendor. Would it be possible to use a Recovery Storage Group to retrieve this data? The mailbox still exists (but may have been moved via Exmerge) so I believe I will pas...

MS Project Server Admin // Denver, CO
MS Project Server Admin Location: Denver, CO Duration: 6 months Pay Rate: DOE =95 MSProject Server ver 2010, SQL database and Sharepoint 2010 =95 Ongoing support and maintenance involving activities such as =96 Monitoring logs, Patches, resolving support tickets, Dev/Test/Prod support =95 Routine troubleshooting =95 Technical APS maintenance (Project Server & SharePoint 2010) =95 User administration / Password resets etc. =95 Work with Microsoft for any critical issues that might need intervention from Microsoft =95 Application of Patches & migration to Production =95 SQL services mo...

Small Business Server in Windows Server 2000 Environment
I have a requirement to install Microsoft CRM for about 10 CRM Users. The existing Windows 2000 has about 120 users with two Exchange Servers. Is it possible to set up a separate Small Business Server to run CRM within the Windows 2000 domain as this is the most cost effective way of implementing CRM for such a low User count? ...

Removed server, exchange still looking for it?
Exchange 5.5, I removed a server from the site using exchange admin, and now am getting event 9318, saying MTA can't contact it. Why is it doing that? I had the same problem after a 5.5 to 2000 migration. Rebooting the Exchange server that was trying to connect resolved the problem. MTA must keep the information cached. Tim "dlw" <dlw@discussions.microsoft.com> wrote in message news:C431500C-F78D-47E5-AAC5-B8C611592E97@microsoft.com... > Exchange 5.5, I removed a server from the site using exchange admin, and > now > am getting event 9318, saying MTA can...

windows 2008 server cord and windows 2008 std
we have 20+ New server to install windows 2008 for trading purpose. still can not decide to install server core or std full, can someone advise what is the benefit to install core rather than std edition or to install std edition ? DD, There is: Server Standard Server Standard Core Server Enterprise Server Enterprise Core Core is (not quite correctly called) 'Server without Graphical User Interface (GUI)'. There are several reasons why Core was introduced: - *Nix purists were saying that there's no real need/use for GUI on a server and *real* sysadmins ar...

Outlook won't leave messages on the server
I have tried and tried to keep Outlook 2003 from deleting my email off my server. I have found the check box under advanced send\receive setting in "options" and I have tried variations of the 3 check boxes in this window and they work until I close Outlook and reopen it, then all of my settings return to the default of deleting my email off the server. Wasn't MS suppose to stop doing things like this? Any help in steering me to the answer (which i am sure is here) to this question is appreciated. Regards Paul A. Walters Hi, Goto Tools --> Email Accounts --> V...

cd burning 11-24-09
okay here's my problem I never used to have problems burning but last year I got a zune mp3 player and it's software converted all my music into zune format now I don't have the mp3 player and have deleted the software and tried to convert the music files back but none of my music will burn it just says "windows encountered a problem while burning file to disc" I really need help with this tell me what I should do ...

Project Server Provisioned
Hello, I have provisioned Project Server and added it to the trusted zone, but it still comes up unresolved. Hello, You mean PWA home page is not loading or issue with connecting from MS Project Professional? Also mention the version of Project Server. Thanks Chak pVector Technologies http://www.pvectortech.com http://www.epmcentral.com On Apr 16, 11:04=A0am, me <mtyso...@yahoo.com> wrote: > Hello, I have provisioned Project Server and added it to the trusted > zone, but it still comes up unresolved. On Apr 16, 12:20=A0pm, Chak <chak...@hotmail.com>...

OT: SVN server
Hi, Sorry for the OT, I am not 100% sure where to ask. I want to setup a subversion repo on a personal website. Would anyone know the best forum/NG to ask such a question? (Or where I could find a tutorial for installing such a repo). Thanks Simon Simon wrote: > Hi, > > Sorry for the OT, I am not 100% sure where to ask. > > I want to setup a subversion repo on a personal website. > Would anyone know the best forum/NG to ask such a question? > (Or where I could find a tutorial for installing such a repo). > > Thanks > > Simon ...

Windows Server 2008 RC2 in Windows Server 2003 Domain
I'm having trouble with one domain controller that has all of the FSMO roles (I have 6 Domain controllers in total running server 2003) I updated my schema to version 47 (Windows server 2008 RC2) and would like to add a new physical server with W2K8 R2 on it and transfer all of the FSMO roles on it. I don't want to upgrade all DC's yet to 2008 R2 yet, so the domain functional level will stay the same for a while (Windows Server 2003). Is there anything I should watch out for with this scenario? Or by just adding a W2k8 R2 box with all the FSMO roles and then decomm...

Exchange Router setup/Setting More than one Exchange Server up in one organisation with two active directories?
Forgive the version difference, but on Exchange 2003 is there a way to install a secondary Exchange Server on a different domain and somehow have it routed to from the other domain or act as a connector to be able to see those emails without removing them? I don't know enough about routing on Exchange to figure if its capable. Or perhaps I need to utilise a different registered email domain and I should use this for testing instead of trying to somehow route emails from one to the other? eg instead of companyname.com I could use companynamecrm.com or something. Would I still want to setu...

pop3 server response
When opening outlook recently it has been saying my pop3 server hasn't respoded in 60 seconds and asks if I would like to wait longer for the server to respond. but sometimes it goes right through. is there any reason why this might be happening. i can only get e-mail about 60% of the time. any help would be greatly appreciated. J.H. Try removing and reinstalling your mail account settings. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the Swen virus, all e-mails sent to my actual account will be deleted w/out reading. After...

Manually run message rules on the server
Hi, Is there a way to run message rules (created by the end-user on Outlook) on the server, say on a daily basis ? The reason is that that person has ~50 rules, moving all incoming messages from his inbox to specific folders. Since he now owns a BES-enabled BlackBerry, these rules prevent him from getting his emails onto his handheld. The idea would be to run all the rules once a day, on his behalf, on the server. Exchange 2007 SP1 Thanks Christian Some rules, like moving messages to another folder in the same mailbox, will run server-side by default, depending on how they're create...

E-Mail Messages Reappear When Server is rebooted
Hello All, I had reason to reboot a windows2003 SBS a few months ago. When it rebooted clients reported old emails had reappeared in their inbox. I was then on a windows2000 SBS site yesterday and when I rebooted the server old emails reappeared. The Windows2003 server rebooted today and again old email reappear. I cannot find any info on web re: this problem. Any help would be appreciated. Sam wrote: > Hello All, > > I had reason to reboot a windows2003 SBS a few months ago. When it > rebooted clients reported old emails had reappeared in their inbox. I > was then on...

web server and exchange server on 2 different servers.
Is there a way to redirect traffic through my web server to my mail server to use OWA with out setting up a front end/back end? If I do have to set up a front end do I have to purchase a separate license? What version of Exchange? If E2k/2003, you have to use FE/BE....and for E2k, the FE server has to be Enterprise. Gonzosez wrote: > Is there a way to redirect traffic through my web server to my mail > server to use OWA with out setting up a front end/back end? > > If I do have to set up a front end do I have to purchase a separate > license? You can install OWA on the w...

MultiFunctional Printers and Server 2008
Hello is there are a way without using TS Server to use a printer that is off location? -- Member - Liberal International This is doctor@nl2k.ab.ca Ici doctor@nl2k.ab.ca God, Queen and country! Never Satan President Republic! Beware AntiChrist rising! http://twitter.com/rootnl2k http://www.facebook.com/dyadallee UK Time for a Common Sense change vote Liberal Democrat / Alliance Yes, there are many ways. You can use print server device, like HP JetDirect. You can attach printer to any networked computer. "The Doctor" <doctor@doctor.nl2k.ab.ca> wrote in message ...

Importing XML data into SQL Server 2005
Hi, We have an app in .NET with sql server 2005 backend and would need to import relatively huge amount of data from disparate providers on a nightly basis. What is the file format that is preferred and please help me understand why we need to go with a specific format? Is it XML, CSV, or anything else? We have been leaning towards using XML If it is XML, how can we a template for the XML file (is it the XSD schema file?) and pass it to the providers so that we can get formatted data without much discrepancies? Thanks in advance! ...

Redeployment 01-12-06
We are replacing the majority of our servers (one of them being out CRM server) and I was wondering if there is a CRM 3.0 redeployment tool like there is for 1.0 and 1.2? Thanks. Yes, there is. It is actually included on the 3.0 media. -- Matt Wittemann http://icu-mscrm.blogspot.com "Danielle Sturgess" wrote: > We are replacing the majority of our servers (one of them being out CRM > server) and I was wondering if there is a CRM 3.0 redeployment tool like > there is for 1.0 and 1.2? > Thanks. > > > Awesome! I didn't even think to check there...

If NIC teaming good or bad for Exch2003 server?
Hi there, For exchange2003 server running on branded server hardware such as HP, if network card teaming (of 2 nics) a good option for exchange2003 or not? How do you guys doing? Just using 1 nic or what? Many thanks! Leemutpo - The good thing about HP is that it will present one virtual NIC to the OS. Generally, unless my client has good network hardware with relatively current IOS levels and good network and server support teams, I will try to steer them clear of NIC teaming. Granted, it is good for redundancy. However, it does have the occasional problem, depe...

Exchange Attributes Missing for New Users after Server Move
Hi, We have recently migrated our Exchange 2003 Enterprise Server by installing the new server on a new platform with a new name in the domain, then used the Move Mailboxes feature. I then followed the procedures in http://support.microsoft.com/kb/822931/ How to remove the first Exchange Server 2003 computer from the administrative group. I shut down the old server and left if configured for December. I have just disposed of the original server (Generation 1 Compaq Proliant). However we have a new user starting today, and although AD seems to add his account as usual, there is no Exchange a...