Does Server.MapPath Behaves Differently In Local Machine And Server Machine

Jul 1, 2010

I have had a real nightmare with Server.MapPath(). When I call Server.MapPath("~") in my application that is running in ASP.NET Development Server it returns root directory that ends in a back slash like f:projectsapp1, but I call it in published version, installed in IIS, it returns root directory without any back slash like c:inetpubwwwrootapp1.

string mainRoot = HttpContext.Current.Server.MapPath("~");
DirectoryInfo di = new DirectoryInfo(mainRoot);
//added to solve this problem with Server.MapPath
if (!mainRoot.EndsWith(@""))
mainRoot += @"";
FileInfo[] files = di.GetFiles("*.aspx");
foreach (FileInfo item in files)
{
string path = item.FullName.Replace(mainRoot, "~/").Replace(@"", "/");
//do more here
}

View 1 Replies


Similar Messages:

How To Get The Local Smtp Server Info From The Local Machine?

Jun 1, 2010

How do I get the smtp server address for the local machine? I want to my email address on a windows form and have the user send me an email and I need to be able to get their smtp server address programatically to do this. I tried this:

System.Net.Mail.
SmtpClient smtpc =
new
SmtpClient("127.0.0.1");
smtpc.Send(email);

It caused an exception.

View 3 Replies

Downloading Files From The Server To The Local Machine In C#?

Jul 24, 2010

In my application I have a requirement where the client/user needs to download video files from the server to their local machine.

View 1 Replies

Configuration :: Using Excel On Web Server, Not On Local Machine?

Jul 23, 2010

With the project I'm working right now, the team and I don't believe the network/computer policies will allow us to create and save Excel files on a local machine through the Web pages we're building. Well, let me clarify. When we run our web pages on our development machines, when we go to save information to excel through the web page, it uses our local excel executable. However, we want it to use the web server's excel executable. When we run the website, we're running individual local copies because we don't have a web server to test on, so we can't verify if it will use the Web Server's or ours. Does anyone know what it will do, or if it has to be programmatically set a specific way to use excel on the web server, and not on the local machine. Once we get the Web Server to use excel, we'd save the file to a network share that would allow the user to view the file.

View 2 Replies

Web Forms :: Copy File From Local Machine To Device Connected To This Machine

Mar 24, 2010

1. ASP.Net WEB server.

2. I have PC, on which file to copy to device is located, with Active Sync installed and IE running which has a page in that IE has rendered by server #1.

3. I have a DEVICE connected to desktop #2 via AS.

I would like to copy file from a local machine to the device which is connected to this machine. My application is located in a webserver.

View 5 Replies

Date And Time Format Different On Local Machine Compared To Production Machine?

Sep 22, 2010

On one of my pages I display a datetime (from a database) and it is formatted correctly as a UK date time (dd-mm-yyyy) on my local machine. However when I deploy it to a server it reverts to American format (mm-dd-yyyy). Does anyone have any idea of when this might be happening?This might be outside the scope of stackoverflow

View 3 Replies

Transfer Database From Local Machine To Hosting Server?

Apr 17, 2010

im trying to transfer my database from local machine to server, im using the publish to provider wizard in visual web developer to generate a scrip, im then using the generated script on the serever database.

[Code]....

View 1 Replies

Login / Logout Work On Local Machine But Not On Server?

Mar 11, 2011

I'm new to ASP.NET (only been learning 6 months at college) and have set up a login page with a loginview, login name and login status. The pages work fine on my local machine I can login logout and see the user name etc..But when I upload this to my home testing server the domain name shows up http://mysite/rootfolder/login.aspx, this should read http://mysite/login.aspx. I've set the DestinationPageUrl as both a direct link and ~/admin.aspx and /admin.aspx

View 17 Replies

Configuration :: Local Machine Wont Work At Server?

Dec 29, 2010

i developed an asp.net web site and i used ModuleRewriter to rename my pages you can refer to this link [URL] and i want to add many pages programatically at run time for example i have a page named :

[URL]styles/defaultstyle/Default.aspx

and i want to display this page like this :

[URL]Default.aspx

so my code was like this :

public static void confgrewriter()
{
try
{
RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;
RewriterRule r = new RewriterRule();
r.LookFor ="~/Dfealut.aspx" ;
r.SendTo ="~/styles/defaultstyle/Default.aspx";
rules.Add(r);
}
catch (Exception ex)
{ }
}

and this solution is working very good on iis at my local machine but when i did upload this website on shared host i recive error message: The resource cannot be found.

Description:

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. review the following URL and make sure that it is spelled correctly.

View 6 Replies

Web Forms :: File Copy From Local Machine To Web Server

Mar 9, 2013

I am attempting to write an asp.net application that copies any file from the user's local machine to another server on the same network.

The Catch

The server that will house the application is separate from the server that will receive the files from the local user's machine. In other words, to do the file copy the user will have to access the application on one server via IIS and within the application it must place that file on another server. Further, these servers while on the same network cannot physically see each other.

In addition, the users of the application are connected Anonymously (Anonymous Authentication)

View 1 Replies

Web Forms :: Accessing Image File In Local Machine From Server?

Sep 14, 2010

i have a .JPG file in my local machine which has to be sent as body of SMTP mail.Path of image D://foldername//imagename.jpg The code I run is in the server mc. I want it to access my local machine's d: folder to get the image file. But it is accessing the server mc's d: folder. How can this be done?

View 3 Replies

Configuration :: Saving Data From Godaddy Server To Local Machine?

Nov 11, 2010

my application raises security issue while saving data from server to local machine.but everything working well locally.

View 2 Replies

Web Forms :: Access Another Server Machine Local Network Area?

Feb 23, 2010

my projects image files hosts on a local server machine which name is A.

another server hosts my web projects on IIS which name is B.

I want to set my web projects's image file names like image1.ImageURL = "A\foldername\image.png";

but when the projects runs the image file url gets the image url adrress : [URl] I must access the image files which are another server machine on my local network area and I must get the ImageUrl properties from another server machine

View 2 Replies

Web Forms :: Page On Dev Server Posts Back To Local Machine?

Jul 22, 2010

Clicking the save button on my webform that's on our dev server:

http://DevServer/Page.aspx

Posts back to the same page on my local machine:

http://LocalMachine/Page.aspx

How does the DevServer even know my computer exists? I haven't hardcoded any URLS in my code.

View 2 Replies

Save Editor.Content To Xml Works On Local Machine But Not On Server?

Mar 25, 2010

I have html editor on page, ajax 3.5. I can save Editor.Content to xml file without problem, after I publish to server machine, It refused to work for me.

my page directive set to ValidateRequest = false and EnableEvenValidate = false and AutoEventWireUp = false, no UpdatePanel used around Editor and update button. on code behind which is button click event.

Dim docInfo.Load(Server.MapPath(xmlInfoFilePath))
docInfo As
New System.Xml.XmlDocument()
Dim ndInfo As System.Xml.XmlNode
ndInfo = docInfo.SelectSingleNode("/info/business[@user='" & User.Identity.Name &
"']")
If ndInfo IsNot
Nothing Then
ndInfo.Attributes("description").Value = Editor.Content
docInfo.Save(Server.MapPath(xmlInfoFilePath))
End If
docInfo = Nothing

This button click generate an error on server side. I guess the problem Editor.Content have hidden tags, the server refuse to accept, but what is real problem.

View 1 Replies

C# - Can Transfer File From Local Machine To Another Machine

Mar 17, 2010

I basically want to transfer a file from the client to the file storage server without actual login to the server so that the client cannot access the storage location on the server directly. I can do this only if i manually login to the storage server through windows login. I dont want to do that. This is a Web-Based Application.

protected void Button1_Click(object sender, EventArgs e)
{
filePath = FileUpload1.FileName;
try
{
WebClient client = new WebClient();
NetworkCredential nc = new NetworkCredential(uName, password);
Uri addy = new Uri("\\192.168.1.3\upload\");
[code]...

View 2 Replies

Getting Appending Html In Csv File (open In Excel) After Download From Server To Local Machine

Dec 9, 2010

I have created a CSV file on the server and want to send it to the user using the following code:

Dim strPhysicalPath As String
strPhysicalPath = Server.MapPath( "CSV/" & PathVirtual)
Dim objFileInfo As System.IO.FileInfo = New System.IO.FileInfo(strPhysicalPath)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment; filename=" & objFileInfo.Name)
Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
Response.WriteFile(strPhysicalPath)
Response.Flush()
Response.End()

This seems to work fine except when the downloaded file is viewed in Excell the html code behind the page from which it came is also appended to the file. Does anyone have any idea why it does this?

View 5 Replies

IIS Configuration :: Web Config Error - It Could However Be Viewed By Browsers Running On Local Server Machine

Jun 5, 2013

When I run my application I got this error

Server Error in '/POD/POMLNT' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
 
What is it means , and how can i fix it ?

View 1 Replies

Configuration :: How To A Give Remote Server Account Read / Write Permissions On Local Machine

Oct 25, 2010

I'm using VS2010 and need to give my remote server asp .net account (IUSR_istereos) access to my local intpub folder

how do I do that?

View 5 Replies

Merge The Records From The Database On The Local Machine With The Records On The Remote Server?

Mar 31, 2010

The website is over half way done and the functionality for the blog is (except for adding posts) is already implemented and working correctlyI have a SQLExpress 2008 backendBlog posts are rendered on the page with full HTML markup within a label control.

All of the above is done and working. Though I am essentially new to creating websites with ASP.NET, CSS and SQL, I am sure that I could simply carry on and make a login page with some controls that would allow me to add records (blog posts) directly to the database on the host server. However, I am fearful of doing this because I know that malicious code can be passed in this way. Also, because of my lack of knowledge, the only way that I know of to pass the code from a control to the database is to disable validation for the page the control is on. Without a doubt I do not want to do that.

So what are my options for getting blog posts into the database? Is it safest for me to fully create the post in html and update a copy of the database that resides on my local machine? If I do it this way, how can I merge the records from the database on the local machine with the records on the remote server?

View 7 Replies

Response.Cookie Client Or Server/where Does The Cookie Saved? On Client Machine Or Server Machine?

Mar 7, 2011

When calling Response.Cookie.Add(new HttpCookie("MyCookie", "objValue")); where does the cookie saved? on Client Machine or Server Machine?

EDIT:if saved in Client Machine, how can I read it from javascript then? I tried this kind of script.

function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
[code].....

I cannot get the cookie that I saved from code behind. When I look into the document.cookie object, it is just an empty string.

Scenario:On Page_Init() on code behind. I create a cookie using Response.Cookie.Add(new HttpCookie("MyCookie", "cookieValue"));.
On Client side, I'm trying to read the cookie saved from code behind on page load using the snippet above, but it returns undefined

View 3 Replies

Does Access To Server Resources Require Client Process To Login To Server Machine

Sep 22, 2010

Reposting my unanswered in technet.microsoft question?

MSDN "ASP.NET Delegation" article tells:

1) "When you configure to use a particular account as the process identity, ASP.NET attempts to delegate that account. If it is a local account that is identical (including password) to a local account on a remote machine, delegation is possible. If such an account does not exist on the remote machine, to the network it appears as the Windows anonymous account (NT AUTHORITYANONYMOUS LOGON). In addition, delegation is also possible if the account is a domain account that has access to the remote machine, in which case it uses the domain network identity of that account."

The same frequently repeated story as in case of manually/interactively accessing remote computer (server resource) in workgroup - it is necessary to create local account with the same username, the same password. But why?

If a workgroup Windows client process cannot access resources on server machine without having duplicate of such (local) account on target machine already pre-created,does it mean that client (process, machine, or user) can access server resources only by/after having logged (opening logon session) into server machine? Or, how to understand that such access is impossible without having corresponding duplicate local account on server machine?

The same MSDN "ASP.NET Delegation" article tells:

"NetworkService account. It behaves the same as the System account. This account possesses the network credentials associated with the machine account (domainnamemachinename) in the domain of which it is a member"

Does not any Windows have accounts ((NT AUTHORITYNETWORK SERVICE)? as well as many other common pre-built accounts? Why are they installed (before any joining to domain) but cannot be used for remote network access and client identification ? And what is identity used when the process from workgroup Windows under identity ((NT AUTHORITYNETWORK SERVICE) accesses a remote server?

My related questions:

domained LocalSystem vs. non-domained LocalSystem account in Windows-es ? how to check group membership of an "NT AUTHORITY" account ? Is client LocalSystem (SYSTEM) identified by target/server machine? and in which context? Window workgroup LocalSystem vs. domain (AD) LocalSystem [closed]how to better set up machine for development both in workgroup and Windows domain? [closed] interoperating with Windows domain computer from workrgroup Windows [closed] the context of local user of AD-joined machine? Is it of domain machine account or of local machine account? RunAs under domain account from non-AD Windows [closed] how to better set up machine for development both in workgroup and Windows domain? [closed] how to share the same domain machine account with multi-boot workgroup Windows setup?

View 1 Replies

SQL Server :: SQL Server Management Studio Express Install On One Machine?

Jan 21, 2011

I have SQL server management studio express install on one machine.

I am able to connect to that machine or able to ping that machine from my computer.

I have code which return me the SQL server instances on same network. Using that I am able to get that SQL server instance. I have configured SQL express to access remote connection. i.e.

Configured SQL express to accept named / TCP IP instance connection. Started Browser service.

My machine settings My machine has been configured to set dynamic IP address using DHCP protocol

When I am trying to connect to above mentioned SQL server I am getting error that "Failed to connect SERVER NAME\SQLEXPRESS".

But if I configured my machine with manual IP address and default gateway I am able to connect to same SQL server.

I got the solution to connect to that server but I don't know why I am facing such problem. And also let me know that is the solution I am using is correct or not?

View 3 Replies

Web Forms :: Differentiate 2k3 Server And Win XP 64 Bit Machine On Server?

Aug 9, 2010

How would i differentiate at server if the request is coming from Win 2k3 machine or Win xp 64 bit machine. I tried using navigator.useragent to find the Client machine OS. But here Windows NT 5.2 is same for both the OS. Is there any way to distinguish it at server.

View 3 Replies

Asp.net - Webservices On Local Machine?

Nov 23, 2010

We have a web service running on the server. We want to use the service in local machine. Could some one kindly give all the steps to get the methods availble in the client.

We have created web methods in the server. And trying to access the same thing on the client. I can literally access those methods using the refernce variable of the server. but when I try to run it , it comes up with run time exception unable to connect to remote server.

View 1 Replies







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