1

Im working on a new company, and they have a classic asp application. Nobody knows how to configure it, so im having a bad time.

The problem is that when the code calls something like that: <img src="/images/TesteiraHome.png" />

on a URL like: http://localhost/myApplication/index.asp

the IIS tries to get the IMG from the URL: http://localhost/images/TesteiraHome.png

How can i set the "base" url for my application, so the iis will try to catch the image from http://localhost/myApplication/images/TesteiraHome.png

Thanks

EDIT: I dont wanna refactor all the project. Isn't there any IIS configuration to make it understand that / means locahost/myapp/ ??

renanleandrof
  • 6,699
  • 9
  • 45
  • 67

3 Answers3

0

well, sticking with HTML you can use the <base> tag:

<base href="http://localhost/myApplication/" />

However, it's probably better to specify the image to runat="server" and use ~/images/TesteiraHome.png as the location. Alternatively, you can use ResolveUrl or ResolveClientUrl:

<img src="<%=ResolveUrl("~/images/TesteiraHome.png")%>" />

And have ASP do it for you.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • I dont wanna refactor all the project. Isn't there any IIS configuration to make it understand that / means locahost/myapp/ ?? – renanleandrof Dec 21 '12 at 15:41
  • Sadly, in the good old days of ASP classic 'runat=server' and 'ResolveUrl' are just things you dream about... – Ted Dec 21 '12 at 16:59
  • 1
    @ted: It can be [emulated](http://stackoverflow.com/a/7972602/298053) though (kinda). ;p – Brad Christie Dec 21 '12 at 17:02
  • Ooh, that looks a bit nicer than the horrible old SITE_URL constant that was littered through our old classic asp sites! – Ted Dec 21 '12 at 17:06
0

Found the solution:

Add a new site on IIS and put the physical path.

Choose it to run on any unused port (for me 8090)

And now it understands that this is the default route.

renanleandrof
  • 6,699
  • 9
  • 45
  • 67
-1

Has it worked successfully in the past? If it has, and it's now been moved to a new server, make sure the site is set up in IIS in the same way as it was originally, i.e. whether it is set as a site, or a virtual directory / application under the default site.

By the looks of it, it should be set up as a site itself, so that the root of the site will be its own directory, rather than wwwroot.

Another, horribly hacky possibility (to avoid any refactoring) would be to simply move the images folder from the site into the root of the wwwroot directory. Not really advisable if you've got any other sites running there though.

Ted
  • 2,525
  • 2
  • 37
  • 54