visual studio .net general:
Hello, We have a asp.net application (I'll call it an application rather than a web-site as it's designed for intranet use, and links in with our "desktop" version of the software) which we've now moved into Visual Studio 2005, after it was initially developed using a text editor. I've got the project working in VS, but have a couple of questions with regards to VS which I'm hoping someone will be able to help me with. I'm finding that, at the moment, VS is actually slowing down my development of the app. When I was creating the app with a simple text editor, and using the command line version of vbc, I'd develop in on my local machine, in a directory which my local copy of IIS pointed to. That worked quite well, and I was used to very quickly being able to make a change to a file, save it, and refresh the browser to see the changes. In VS, at the moment, if I make a change to the site, I have to go to the build menu, and select "publish site" to see any changes. The application contains a large number of aspx, ascx and .vb files, and the process of building the site takes sometime. I know that I can "run" a page by using F5 or Ctrl+F5 within VS (using the ASP.net development server), but that doesn't work very well for me for the following reasons: 1) All the pages on the site are protected via form protection in the web.config file, which means that if I try to start any page using F5, I get redirected to the login page (as I would expect), but when I login to the site, I always get a 404 error. 2) All my pages rely on CSS files, but when viewing a file (eg, the login screen, as that's the only one I can see!), it doesn't pick up the CSS file, so all my formatting is non-existent. I was kinda hoping I could simply point my local copy of IIS to the directory containing the code, but that's not going to work because the bin directory doesn't exist, so all my objects won't be found. I'm sure this is simply because I'm new to web development using VS (although I've done .net mobile development in VS before). Any help would be appreciated! - Especially the easiest way for me to quickly view the complete site without having to publish each time, Thanks! A.
Okay - I've got around that problem - It's because the ASP.net development server uses a virtual directory, and quite a bit of my code assumes it's in the root (eg, I'm referencing my css by "/filename.css"). The problem is that I have hundreds of ASPX files in tens of directories, sometimes many directories deep - Because I knew I was in the root, I could previously always do a "/filename.css" without worrying about it, but now I need to change them to "../../../filename.css" - The number of "../"'s depending on the directory the file is in. I could create my own basepage, from which all pages inherit, and put some code in there which figures out when the file is, and references the css file accordingly (eg, adds "x" number of "../" to the href). But that seems a little wasteful. Is there a better way of doing it? I guess what I need really is an asp.net var which always points to the current virtual directory? A. [quoted text, click to view] "Adds" <adds21@yahoo.com> wrote in message news:voPWf.149852$zk4.116092@fe3.news.blueyonder.co.uk... > Hello, > > We have a asp.net application (I'll call it an application rather than a > web-site as it's designed for intranet use, and links in with our > "desktop" version of the software) which we've now moved into Visual > Studio 2005, after it was initially developed using a text editor. > > I've got the project working in VS, but have a couple of questions with > regards to VS which I'm hoping someone will be able to help me with. > > I'm finding that, at the moment, VS is actually slowing down my > development of the app. When I was creating the app with a simple text > editor, and using the command line version of vbc, I'd develop in on my > local machine, in a directory which my local copy of IIS pointed to. That > worked quite well, and I was used to very quickly being able to make a > change to a file, save it, and refresh the browser to see the changes. > > In VS, at the moment, if I make a change to the site, I have to go to the > build menu, and select "publish site" to see any changes. The application > contains a large number of aspx, ascx and .vb files, and the process of > building the site takes sometime. > > I know that I can "run" a page by using F5 or Ctrl+F5 within VS (using the > ASP.net development server), but that doesn't work very well for me for > the following reasons: > > 1) All the pages on the site are protected via form protection in the > web.config file, which means that if I try to start any page using F5, I > get redirected to the login page (as I would expect), but when I login to > the site, I always get a 404 error. > > 2) All my pages rely on CSS files, but when viewing a file (eg, the login > screen, as that's the only one I can see!), it doesn't pick up the CSS > file, so all my formatting is non-existent. > > I was kinda hoping I could simply point my local copy of IIS to the > directory containing the code, but that's not going to work because the > bin directory doesn't exist, so all my objects won't be found. > > I'm sure this is simply because I'm new to web development using VS > (although I've done .net mobile development in VS before). > > Any help would be appreciated! - Especially the easiest way for me to > quickly view the complete site without having to publish each time, > > Thanks! > A. > >
Hi, [quoted text, click to view] > server uses a virtual directory, and quite a bit of my code assumes it's in > the root (eg, I'm referencing my css by "/filename.css").
This is nearly always wrong. This isn't an ASP.NET issue, it's fundamental to creating any web site. One trick you can use with dynamic driven sites is to get the page to "know" where it resides within the folder structure, then you can reference other pages using a relative URL. PERL is very good at this; in classic ASP you'd find Server.MapPath useful. Have a look at the HostingEnvironment Class in the .NET Framework docs; it's got a nice C# example of all the different kinds of mappings you can do with both physical and virtual directories. --
Try using: "~/filename.css" This should work for you. [quoted text, click to view] "Adds" wrote: > Okay - I've got around that problem - It's because the ASP.net development > server uses a virtual directory, and quite a bit of my code assumes it's in > the root (eg, I'm referencing my css by "/filename.css"). > > The problem is that I have hundreds of ASPX files in tens of directories, > sometimes many directories deep - Because I knew I was in the root, I could > previously always do a "/filename.css" without worrying about it, but now I > need to change them to "../../../filename.css" - The number of "../"'s > depending on the directory the file is in. > > I could create my own basepage, from which all pages inherit, and put some > code in there which figures out when the file is, and references the css > file accordingly (eg, adds "x" number of "../" to the href). But that seems > a little wasteful. Is there a better way of doing it? I guess what I need > really is an asp.net var which always points to the current virtual > directory? > > A. > > > "Adds" <adds21@yahoo.com> wrote in message > news:voPWf.149852$zk4.116092@fe3.news.blueyonder.co.uk... > > Hello, > > > > We have a asp.net application (I'll call it an application rather than a > > web-site as it's designed for intranet use, and links in with our > > "desktop" version of the software) which we've now moved into Visual > > Studio 2005, after it was initially developed using a text editor. > > > > I've got the project working in VS, but have a couple of questions with > > regards to VS which I'm hoping someone will be able to help me with. > > > > I'm finding that, at the moment, VS is actually slowing down my > > development of the app. When I was creating the app with a simple text > > editor, and using the command line version of vbc, I'd develop in on my > > local machine, in a directory which my local copy of IIS pointed to. That > > worked quite well, and I was used to very quickly being able to make a > > change to a file, save it, and refresh the browser to see the changes. > > > > In VS, at the moment, if I make a change to the site, I have to go to the > > build menu, and select "publish site" to see any changes. The application > > contains a large number of aspx, ascx and .vb files, and the process of > > building the site takes sometime. > > > > I know that I can "run" a page by using F5 or Ctrl+F5 within VS (using the > > ASP.net development server), but that doesn't work very well for me for > > the following reasons: > > > > 1) All the pages on the site are protected via form protection in the > > web.config file, which means that if I try to start any page using F5, I > > get redirected to the login page (as I would expect), but when I login to > > the site, I always get a 404 error. > > > > 2) All my pages rely on CSS files, but when viewing a file (eg, the login > > screen, as that's the only one I can see!), it doesn't pick up the CSS > > file, so all my formatting is non-existent. > > > > I was kinda hoping I could simply point my local copy of IIS to the > > directory containing the code, but that's not going to work because the > > bin directory doesn't exist, so all my objects won't be found. > > > > I'm sure this is simply because I'm new to web development using VS > > (although I've done .net mobile development in VS before). > > > > Any help would be appreciated! - Especially the easiest way for me to > > quickly view the complete site without having to publish each time, > > > > Thanks! > > A. > > > > > >
Don't see what you're looking for? Try a search.
|