Favicon is displayed fine if the URL have no querystring, while it does't show if the URL contain querystring!!
Here are the page without querystring:
www.NoonOffer.com
Here are the page with querystring
http://www.noonoffer.com/Offers.aspx/7/Pay-LE-50-and-get-50-discount-on-PMP-course
Any suggestions?
Your url doesn't appear to be correct. Something in your code is not putting the proper URL in the HREF.
It is:
http://www.noonoffer.com/Offers.aspx/7/favicon.png
Should be:
http://www.noonoffer.com/favicon.png
EDIT: Not sure with .NET, but using Core Tag Library with Java Spring MVC a "/" at the front of the URL will make a difference when using relative paths.
This would append it to the end of the URI I believe:
<c:url value="/favicon.png">
And I believe this would append it to the context root like you want.
<c:url value="favicon.png">
This may not be the exact issue, but I hope it will help.
Related
In ASP having this URL:
http://www.example.com?foo=1&bar=2
Request.QueryString["bar"] returns NULL
The URL is a map area "href" link which I have assigned like so:
PolygonHotSpot p = new PolygonHotSpot();
p.NavigateUrl = http://www.example.com?foo=1&bar=2
ASP automatically HTML encodes the URL for the href, but it is not HTML decoding it again in the request therefore query string "bar" is not found.
Now I am using IIS URL Rewrite 2 module. Maybe this module is causing the problem? What can I do to solve it? I have tried using URL rewrite rules but couldn't figure our how or if it is the proper way.
It's probably not a good idea, but you could use Request.ServerVariables("QUERY_STRING") (or Request.ServerVariables["QUERY_STRING"] - your tags say ASP classic but your code looks like C#?) to get at the entire thing and then process it yourself.
I think there must be something deeper wrong though. A link can be encoded to be sent to the browser - the browser does the work of decoding it before navigating to the link. You can demonstrate this with a simple <a href="/test?a=1&b=2"> in a test script - the browser ends up correctly at /test?a=1&b=2. Testing it with a polygonal image map shows the same behaviour.
If you can show me what is in your actual HTML output for the image map I might be able to help more.
I have a website which i run localy and the path on the browser is
"http://localhost:3184/basel/index.aspx"
I have a menu which contains various hyperlinks and one of them is:
//This will evaluate to http://localhost:3184/basel/en/open-account/index.aspx.
The hyperlink will redirect me the page above, After that when i try to click the same link again on the menu, the path of the page is the following:
"http://localhost:3184/basel/en/open-account/en/open-account/index.aspx"
Why is it that the path have duplicated, i have been struggling for a while but can't seem to figure this out, Any solution ?
Try this:
Using the tilde creates an application-relative path.
What is in your code behind? If the A tag is being set dynamically (maybe something like this myHyperlink.NavigateURL += "en/open-account/index.aspx";) then each time the page is loaded the URL will have a new value appended to the end.
Maybe check the code behind to see if this URL is being manipulated there? If you've already done so, my apologies :)
Use Page.ResolveUrl() method. If the relativeUrl have an absolute URL, the URL is returned unchanged. If the relativeUrl have contains a relative URL, that URL is changed to a relative URL that is correct for the current request path, so that the browser can resolve the URL
I'm using the iis7 URL Rewrite module and it's working fine, except for two things. Being new to this, I might be missing something obvious.
1) My URL gets converted from
www.mysite.com/search.aspx?fName=John&sName=Smith
to www.mysite.com/John/Smith. This works fine, but if I add a trailing / , a few images on the site disappear, wheras a few don't. (They're all in the same location). However, the search results are fine.
2) Is it possible to make cerain querystrings optional? Server side, this is implemented (i.e. if nothing is entered, then assume a default value). But how would this work with the URL rewrite module?
e.g. www.mysite.com/John would search for John and use a default value for the sName parameter.
Thanks for any help.
I can't help with the optional query string parameters I'm afraid, but the images one should be fairly easy:
How are you declaring the image paths in your markup? If you are using relative paths (i.e. src="../Images/someimage.png" then adding a trailing slash to the URL is telling the browser that the /Images/ folder is under the folder /John/ instead of being at the root of the site.
If you are using HTML <img /> tags, you should prefer a virtual path: src="/Images/someimage.png" - this tells the browser to request the image path from the root of your site.
If your application isn't running in the root of the site, you can also use the ResolveUrl method that is part of the page and control object tree, this allows you to pass in a virtual path of the form ~/Images/someimage.png and the framework will work out what the correct path should be.
I tried using the IHttpModule and managed to convert the urls just fine,
but all of my images returned path error (all going through the new url directory).
whats the solution?
You need to make sure that you use the "~/" path notation on your images and make sure that they are all server controls with runat='server'. Otherwise the images urls won't get rewritten.
For example if you have a page that gets rewritten from:
/Item/Bicycle.aspx
to
/Item.aspx?id=1234
Then what will happen is that an image reference like this:
<img src='images/something.gif' />
will break. So instead you have to do something like this:
<asp:image imageurl='~/images/something.gif' runat='server' id='img1'/>
Alternatively you can use absolute paths for your images. Or you can push as much as possible into your .css files.
You can try using a URL rewriter such as IIRF.
With IIRF you can use regular expressions to parse the incoming URL as you wish, then send it to the right place.
They have examples built in on how to do all that in the IIRF download.
What's the solution? Use the new routing engine in .NET 3.5 that started in the MVC project and got elevated to stand-alone status. :)
If Keltex's suggestion doesn't solve your specific problem look at ResolveUrl and ResolveClientUrl.
I'm using http://urlrewriter.net/ to rewrite urls at my website. For example, I'm rewriting:
http://www.example.com/schedule.aspx?state=ca
to
http://www.example.com/california.aspx
What I'm trying to do (for SEO purposes) to to dynamically add the meta tag:
<meta name="robots" content="noindex,follow" />
only to the page that hasn't been rewritten. This is because I want both URLs to work, but only the rewritten one to be indexed by search engines.
How do I determine which version of the page has been requested?
EDIT
Answers below suggest a 301 redirect instead of using a meta tag. Maybe I'll do this, but I still want to know the answer to the underlying question... how do I know if the page has been rewritten?
personally, I would 301 redirect from the un-rewritten one to the re-written one, and only use the single copy of the page. It is easier for users, and from an SEO perspective, you have 1 copy of the content.
If you need to do this you can probably do something like:
<add header="X-WasRewritten" value="true" />
And you can check for the header in your view and add the robots meta tag if you need it.
This will get returned to the client too, so if you want to hide that you can write a CustomAction (http://urlrewriter.net/index.php/support/reference/actions/custom-action) which will set some kind of state value in your request.
However, having two URIs for the same resource is something I would not recommend. I suggest you just keep the one representation. If you're worried about invalidating old bookmarks you can set the old one to redirect to the new one.
Further to chakrit's answer, it looks like UrlRewriter.NET stores the original URL in the HttpContext, in a key called UrlRewriter.NET.RawUrl. So, you could try something like:
bool isPageRewritten =
!string.IsNullOrEmpty(HttpContext.Current.Items["UrlRewriter.NET.RawUrl"]);
Most obvious method is to use the Request.Url object in your page to get information about the URL and query string. For example:
if (Path.GetFileName(Request.Url.FilePath) == "schedule.aspx")
//Not rewritten
else
//rewritten
I think that's the job of HttpContext.Current.Items.
You can save the "Redirection" in HttpContext.Current.Items and then in your pages, you can check it for a certain added value.
I believe you can add hooks to urlrewriter.net that could do it, something alongs:
HttpContext.Current.Items["Redirected_From"] = currentUrlHere;
And then in your webpages, you could check it by:
if (!string.IsNullOrEmpty(HttpContext.Current.Items["Redirected_From"]))
// the page's been redirected, do something!
else
// no it's visited normally.
I have long since left it for the ASP.NET Routing framework in .NET 3.5 SP1, it is better than urlrewriter.net IMO.