views:

753

answers:

1

In our setup there are two different websites in IIS 7 setup that point to the same physical path. One with the binding http://websitename.domain.com/ (virtual root ~ is /)

and the second at https://webserver.domain.com/userid/websitename (so the virtual root ~ is /userid/websitename). We use the second for secure aspects of each website.

This causes a problem with the loading of the Webresources.axd files for generated css, and javascript for the AJAX.net toolkit.

Is there a way to have the path to these generated resource files modified. Or somehow set the virtual root path per application.

+1  A: 

I found one solution, using the Render() method to replace the url paths with the correct one. This forum post has info on this solution. I'll have to modify it to check the Request.Url to see which domain the page request is coming from.

protected override void Render(HtmlTextWriter writer)
{
     try
     {                  
          StringBuilder renderedOutput = new StringBuilder();    
          StringWriter strWriter = new StringWriter(renderedOutput);    
          HtmlTextWriter tWriter = new HtmlTextWriter(strWriter);    
          base.Render(tWriter);

          //this string is to be searched for src="/" mce_src="/" and replace it with correct src="./" mce_src="./". 

          string s = renderedOutput.ToString();
          s = Regex.Replace(s, "(?<=<img[^>]*)(src=\\\"/)", "src=\"./", RegexOptions.IgnoreCase);
          s = Regex.Replace(s, "(?<=<script[^>]*)(src=\\\"/)", "src=\"./", RegexOptions.IgnoreCase);
          s = Regex.Replace(s, "(?<=<a[^>]*)(href=\\\"/)", "href=\"./", RegexOptions.IgnoreCase);

          writer.Write(s);
      }
      catch
      {
      }
  }
}
Steve Tranby