I plan to deploy my ASP.Net project on a target server.I intend to have a JavaScript file for download at the target server which the client would download.
The javascript file which is to be run at the client would need to access a file stored at the target server.
Now,my question is how do I make my JavaScript file include the URL of the file(which is to be accessed) at the target server(as I have no control over where my project could be deployed on the target machine)
I hope my question is clear.I would really appreciate some help in this.
The filesystem of the server is irrelevant when providing a URL. In fact, providing a link containing a filesystem path won't work for downloads, unless the client is physically mapped to the server. Your URL will be known at deployment. It will be http://www.yoursite.com.
Clientside javascript won't be able to access files on your server unless they are made available in a publicly accessible folder, such as your web root or below.
Thnks for your reply.I am going to be put the files in my web root. But I have no control over the folder in the webroot folder where the the application is going to be stored and hence where the file is going to reside.
For eg: it could be http://localhost/sample1/file.txt (If the target server location is C:\inetpub\wwwroot\sample1)
or it could be also be http://localhost/sample2/file.txt (If the target server location is C:\inetpub\wwwroot\sample2)
So what I need to know is is there anyway I can somehow find out the URL of the file and somehow pass that information to the JS file,so that when the client downloads the JS file,it contains the correct URL
Will you be creating folders to house the files dynamically? Otherwise how could you not know the virtual path? Incidentally, the URL will never be http://locahost unless the application only resides on your computer.
I created a web setup deployment project which installs the web application in the target server.When the .msi file is run in the target,it gives the option to the person running the setup file to mention the name of the virtual directory which is going
to house the application and hence the files.It is the folder name(which as u say is dynamic in the sense that it is going to be created during the time app is installed) which i am trying to determine to write in my JS file.
and like you said,my URL in the final sense wont be http://localhost.. but right now I am just testing it on my local machine and a separate target machine..
OK. It doesn't matter what the name of the folder is that will house your app. It will be created as a virtual directory and will be accessible from http://www.yourdomain.com. The directory you have created for the files will be installed with the same name
under this virtual directory as you have in your test setup, and will be accessible from http://www.yourdomain.com/your_file_directory
But when I install from the msi file in the target server,the option is given to change the name of the virtual directory.So a change in the name of the virtual directory would change the value of the URL.
So I wanted to know if it is possible for me to somehow get the new name of the virtual directory to reflect the changed URL
It's very clear that you don't understand the difference between a URL and a file path. They are not the same thing. The name of the virtual directory belongs to the server's file path, and has nothing to do with URLs. To offer a download, you have to provide
a URL. Since the name of the virtual directory has nothing to do with URLs, you don't need to know the name of it.
I think I have worked out the cause of your confusion. I suspect you are using Windows XP Pro and IIS 5.1 to create and test your applications. If this is the case, IIS 5.1 will only allow you to create one "web site" by default. This runs under localhost.
If you want ot create any more sites or projects, you have to put them in folders under wwwroot, and browse to them as http://localhost/myproject1 or http://localhost/myproject2 etc. You know that the myproject1 folder contains your "site", but as far as
IIS 5.1 is concerned, that's just a subfolder of the default site.
IIS 5.1 is NOT a proper web server. When you deploy your application on a proper server, such as IIS 6.0 or 7.0, the files get put into a virtual directory. It doesn't matter what this is called, because the domain of your site is mapped to that directory.
When you want to run a page in your app, you now request http://www.mydomain.com/mypage.aspx. http://www.mydomain.com is an alias for the virtual directory. The mapping is taken care of behind the scenes. All the files and subfolders are placed identically
in relation to the root folder/virtual directory (which is now know as http://www.mydomain.com from outside the web server) and can be referenced in an identical way to the structure on your PC. ie /subfolder1 or /subfolder2/page3.aspx etc.
If you are using XP Pro, hopefully this will make things clearer for you. You might also be interested in a tool from
jetstat.com called IISAdmin. It's a free download that allows you to create multiple sites on IIS 5.1. You can still only run one site at a time, but whichever one you are running will be reached at just http://locahost.
i have no control over wat version of IIS is going to be in use in the target server.Nor do i have the control over installing the tool on the target server.
I guess I dont have any other options then right?
Is there any way that I can make sure that the virtual directory which is created at the target server always has the same name? I mean can i remove the option of the user having the ability to change the name of the virtual directory which is created at
the target server?
Satishr23
Member
101 Points
43 Posts
Finding the path of the virtual directory in the target server
Apr 30, 2007 05:29 AM|LINK
Hi,
I plan to deploy my ASP.Net project on a target server.I intend to have a JavaScript file for download at the target server which the client would download.
The javascript file which is to be run at the client would need to access a file stored at the target server.
Now,my question is how do I make my JavaScript file include the URL of the file(which is to be accessed) at the target server(as I have no control over where my project could be deployed on the target machine)
I hope my question is clear.I would really appreciate some help in this.
thanks
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 07:52 AM|LINK
Web Pages CMS | My Site | Twitter
Satishr23
Member
101 Points
43 Posts
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 11:14 AM|LINK
Hi,
Thnks for your reply.I am going to be put the files in my web root. But I have no control over the folder in the webroot folder where the the application is going to be stored and hence where the file is going to reside.
For eg: it could be http://localhost/sample1/file.txt (If the target server location is C:\inetpub\wwwroot\sample1)
or it could be also be http://localhost/sample2/file.txt (If the target server location is C:\inetpub\wwwroot\sample2)
So what I need to know is is there anyway I can somehow find out the URL of the file and somehow pass that information to the JS file,so that when the client downloads the JS file,it contains the correct URL
thanks
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 11:25 AM|LINK
Web Pages CMS | My Site | Twitter
Satishr23
Member
101 Points
43 Posts
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 11:43 AM|LINK
Hi,
I created a web setup deployment project which installs the web application in the target server.When the .msi file is run in the target,it gives the option to the person running the setup file to mention the name of the virtual directory which is going to house the application and hence the files.It is the folder name(which as u say is dynamic in the sense that it is going to be created during the time app is installed) which i am trying to determine to write in my JS file.
and like you said,my URL in the final sense wont be http://localhost.. but right now I am just testing it on my local machine and a separate target machine..
thanks for all your replies
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 12:37 PM|LINK
Web Pages CMS | My Site | Twitter
Satishr23
Member
101 Points
43 Posts
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 03:05 PM|LINK
But when I install from the msi file in the target server,the option is given to change the name of the virtual directory.So a change in the name of the virtual directory would change the value of the URL.
So I wanted to know if it is possible for me to somehow get the new name of the virtual directory to reflect the changed URL
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 04:05 PM|LINK
Web Pages CMS | My Site | Twitter
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Finding the path of the virtual directory in the target server
Apr 30, 2007 07:30 PM|LINK
I think I have worked out the cause of your confusion. I suspect you are using Windows XP Pro and IIS 5.1 to create and test your applications. If this is the case, IIS 5.1 will only allow you to create one "web site" by default. This runs under localhost. If you want ot create any more sites or projects, you have to put them in folders under wwwroot, and browse to them as http://localhost/myproject1 or http://localhost/myproject2 etc. You know that the myproject1 folder contains your "site", but as far as IIS 5.1 is concerned, that's just a subfolder of the default site.
IIS 5.1 is NOT a proper web server. When you deploy your application on a proper server, such as IIS 6.0 or 7.0, the files get put into a virtual directory. It doesn't matter what this is called, because the domain of your site is mapped to that directory. When you want to run a page in your app, you now request http://www.mydomain.com/mypage.aspx. http://www.mydomain.com is an alias for the virtual directory. The mapping is taken care of behind the scenes. All the files and subfolders are placed identically in relation to the root folder/virtual directory (which is now know as http://www.mydomain.com from outside the web server) and can be referenced in an identical way to the structure on your PC. ie /subfolder1 or /subfolder2/page3.aspx etc.
If you are using XP Pro, hopefully this will make things clearer for you. You might also be interested in a tool from jetstat.com called IISAdmin. It's a free download that allows you to create multiple sites on IIS 5.1. You can still only run one site at a time, but whichever one you are running will be reached at just http://locahost.
Web Pages CMS | My Site | Twitter
Satishr23
Member
101 Points
43 Posts
Re: Finding the path of the virtual directory in the target server
May 01, 2007 01:34 AM|LINK
Hi,
thanks for all ur help.i really appreciate this..
i am using windows xp with IIS 5.1.
i have no control over wat version of IIS is going to be in use in the target server.Nor do i have the control over installing the tool on the target server.
I guess I dont have any other options then right?
Is there any way that I can make sure that the virtual directory which is created at the target server always has the same name? I mean can i remove the option of the user having the ability to change the name of the virtual directory which is created at the target server?
thnks again