Webresource.axd issue between normal and secure domains
Our installation has two different sites in the IIS 7 setup that point to the same physical path. One with the bindings http: // websitename .domain.com / (virtual root ~ is /)
and the second is https://webserver.domain.com/ userid / websitename (so virtual root ~ is / userid / websitename). We use the second one for the secured aspects of each website.
This causes a problem loading the Webresources.axd files for the generated css and javascript for the AJAX.net toolkit.
Is there a way to change the path to these generated resource files. Or somehow set a virtual root path for each application.
source to share
I found one solution using the Render () method to replace the URL paths with the correct one. This forum post contains information about this solution. I will need to change it to check 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
{
}
}
}
source to share