not having to encode url - asp.net-mvc

Say I have this url "/my#stuff"
I am using asp.net mvc and when I try to goto this page it takes me to just "/my". The "#stuff" part has been removed.
Now I can get it to work fine if I encode the URL like so "/my%23stuff" since %23 decodes to #
However, is there a way I can get this to work without having to encode the url?
I'd like it if typing in "/my#stuff" as the URL worked just the same as "my%23stuff"

I don't think there is a way to do what you are saying. The hash is used in a URL for anchor tags.
You are pointing at a page /my and navigating to anchor tag "stuff" on that page. If anchor tag "stuff" does not exist it will just navigate to page /my.

Related

GlassMapper Link not rendered when %20 in subject

I have an interesting situation where I am trying to render a link which could be a URL to a site or a mailTo tag.
The issue is that when I put any spaces in the subject field these get converted into %20's when I save the link then the link doesn't get pulled into the rendering at all (it just returns null in the view).
Interestingly if I manually remove the %20's after I save the link (this can be done in the page editor) the link comes through fine!
Now if I save and publish the link returns null but if I manually edit and remove the %20 GlassMapper grabs the link fine.
Any ideas why GlassMapper wont get the link when there is %20's in there?

ZF2: Who should escape & delimiter for href when using Url helper?

When I use url helper to generate url for route with query params and then add that url to link href, validator warns me, that there is unescaped & in attribute:
▲
I tried to search but still I'm not sure who is responsible for escaping that.
Router generates url but that might be used anywhere, not only in html attribute, so it correctly does no escaping in his case.
Url helper does not change anything in that url but it is meand for use in html so it might done here
View template - there url is put inside href attribute, so it might be here too
I couldn't find any clue how to decide this and if fill an issue with zf2 about this.
EDIT: html/php code from paginator
<<
generates html
<<
and from what I found it should be
<<
I would argue that the current behavior (not HTML entity encoding) is correct and it is up to the developer to encode HTML entities, when appropriate.
For instance you may want to use the view helper inside a <script> tag, where the HTML entities would be uncalled for.

where does the href inside an <a> tag link direct me?

If I were to put
Replace this
where does this link go to? I am using eldarion-ajax and the examples all use this link location.
Does this link to replace.html?
the div with id #replace
It probably just goes to the url "replace". like if you're at www.website.com/index.html it would go to www.website.com/replace. It's probably just a placeholder indicating you should replace it with another value.
Web URLs do not need to end in .html or such.

Anchor links don't work on pages with query strings

I've become dumbfounded by this. This might be something that I've just assumed worked all along, but in fact has never worked.
I've got an anchor link on a page [Activities] and later on the page I have the anchor <a name="activities"></a>. This is the URL of the page: https://iassid.org/index.php?option=com_content&id=216
For some reason, the anchor link on the page brings the user back to https://iassid.org/index.php#activities
Has removing the query string always been normal behavior? The href in the anchor tag doesn't include anything but the hash, why would it even assume to go off the page? Why does it go back to the original URL without the query string? Is there any way to get this to work without putting the entire URL including the query string in the URL as well? I'm trying to make this easy for someone who isn't very familiar with HTML, so using onclick events and other options aren't desired.
Maybe I've just been crazy to assume this would work all along! Thanks for any insights.

Can I use canonical URL on the same page it links to?

I want to ask about canonical URL. Lets assume this URL structure:
/category_A/page1
/category_B/page1
/category_C/page1
Simply put, there are multiple URLs that display the same content. But only /category_A/page1 is original(canonical) page. My question is if it have any impact(bad/good/neutral) considering SEO if I will have canonical URL pointing to /category_A/page1 placed in this same page /category_A/page1 ?
The reason for this is, that its much easier to just put canonical URL into head of every page than to trying find out in which page it is not needed (its the same page as canonical one)
just do it
you described the perfect use case for the canonical tag. the canonical tag is a kind of failsafe against wrong URLs (or URLs with unnecessary parameters). so it's good to have it even on the page with the URL the canonical points to.

Resources