ASP.Net pages relative paths? - asp.net

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

Related

How to link images and pages in wordpress pages?

So, in the WordPress page, I need to link the pdf in wp-contents so I linked it with the relative URL as href="/wp-content/uploads/2017/03/test.pdf"
when I click it since my root in localhost is localhost/test it takes me to localhost/wp-content/uploads/2017/03/test.pdf (which doesn't serve the file). However, I don't think it'll be an issue in the server. Still, I want to know if this is the correct way?
Also, so I'm in page localhost/test/page22 Now on the page, I have an anchor tag as href="/page23" it takes me to page23 correctly, but when I'm in a different sub page say localhost/test/page/page2 now, the link takes me to localhost/test/page/page23 which is not correct as it should be localhost/test/page23. How can I solve these issues
WordPress provides functions for getting the URL of resources you should use these instead of having your code generate the URL. In this case you should call wp_get_attachment_url().

favicon not show if page have querystring

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.

DRUPAL broken images after enabling url rewriting

I turned on URL rewriting on Drupal, and some URL image are broken.
For example :
local/tw/sites/all/themes/tw/images/1-p1.jpg become
local/tw/content/sites/all/themes/tw/images/1-p1.jpg
or
local/tw/sites/all/themes/tw/images/2-p1.jpg become
local/tw/node/sites/all/themes/tw/images/2-p1.jpg
Any ideas?
If you used relative path, and you're talking about contents within nodes, it's perfectly normal, since "node/" is interpreted like a directory.
You could fix this problem adding a "/" before image src, or using module like Path Filter that provides a simple file:relative/path/to/file syntax.

Problem passing parameters via Iframe in IE

I'm trying to execute an HTTP GET from my website to another website that is brought in via iframe.
On Firefox, you can see in the source that the correct url is in the iframe src along with it's correct parameters-- and it works.
On IE, you can see in the source that the correct url is in the iframe src along with it's correct parameters-- and it doesn't work...
Is there something about IE that doesn't let you pass parameters through an iframe in the querystring?
I've tried refreshing the iframe in IE, I've tried refreshing my page & the iframe in IE, and I've tried copying the url and re-pasting it into the iframe src (forcing it to refresh as if I just entered it into the address bar for that iframe window). Still no luck!
Anyone know why this is happening, or have any suggestions to try to get around this?
Edit: I cannot give a link to this because the site requires a password and login credentials to both our site and our vendor's site. Even though I could make a test account on our site, it would not do any good for the testing process because I cannot do the same for the vendor site. As for the code, all it's doing is creating the src from the backend code on page load and setting the src attribute from the back end...
//Backend code to set src
mainIframe.Attributes["src"] = srcWeJustCreated;
//Front end iframe code
<iframe id="mainIframe" runat="server" />
Edit: Problem was never solved. Answer auto accepted because the bounty expired. I will re-ask this question with more info and a link to the page when our site is closer to going live.
Thanks,
Matt
By the default security settings in IE query parameters are blocked in Iframes. On the security tab under internet options set your security level to low. If this fixes your problem then you know that is your issue. If the site is for external customers then expecting them to turn down their security settings is probably unreasonable, so you may have to find a work around.
Let's say your site is www.acme.com and the iframe source is at www.myvendor.com.
IIRC, most domain-level security settings don't care about the hostname, so add a DNS CNAME to your zone file for myvendor.acme.com, pointed back to www.myvendor.com. Then, in your IFRAME, set the source using your hostname alias.
Another solution might be to have your Javascript set the src to a redirector script on your own server (and, thus, within your domain). Your script would then simply redirect the IFRAME to the "correct" URL with the same parameters.
If it suits you, you can communicate between sites with fragment identifiers. You can find an article here: http://tagneto.blogspot.com/2006/06/cross-domain-frame-communication-with.html
What BYK said. I think what's happening is you are GETting a URL that is too large for IE to handle. I notice you are trying to send variable named src, which is probably very long, over 4k. I ran into this problem before, and this was my code. Notice the comment about IE. Also notice it causes a problem with Firefox then, which is addressed in another comment.
var autoSaveFrame = window.frames['autosave'];
// try to create a temp form object to submit via post, as sending the browser to a very very long URL causes problems for the server and in IE with GET requests.
var host = document.location.host;
var protocol = document.location.protocol;
// Create a form
var f = autoSaveFrame.document.createElement("form");
// Add it to the document body
autoSaveFrame.document.body.appendChild(f);
// Add action and method attributes
f.action = protocol + '//' + host + "/autosave.php"; // firefox requires a COMPLETE url for some reason! Less a cryptic error results!
f.method = "POST"
var postInput = autoSaveFrame.document.createElement('input');
postInput.type = 'text'
postInput.name = 'post';
postInput.value = post;
f.appendChild(postInput);
//alert(f.elements['post'].value.length);
// Call the form's submit method
f.submit();
Based on Mike's answer, the easiest solution in your case would be to use "parameter hiding" to convert all GET parameters into a single URL.
The most scalable way would be for each 'folder' in the URL to consist of the parameter, then a comma, then the value. For example you would use these URLs in your app:
http://example.com/app/param,value/otherparam,othervalue
http://example.com/app/param,value/thirdparam,value3
Which would be the equivalent of these:
http://example.com/app?param=value&otherparam=othervalue
http://example.com/app?param=value&thirdparam=value3
This is pretty easy on Apache with .htaccess, but it looks like you're using IIS so I'll leave it up to you to research the exact implementation.
EDIT: just came back to this and realised it wouldn't be possible for you to implement the above on a different domain if you don't own it :p However, you can do it server-side like this:
Set up the above parameter-hiding on your own server as a special script (might not be necessary if IE doesn't mind GET from the same server).
In Javascript, build the static-looking URL from the various parameters.
Have the script on your server use the parameters and read the external URL and output it, i.e. get the content server-side. This question may help you with that.
So your iframe URL would be:
http://yoursite.com/app/param,value/otherparam,othervalue
And that page would read and display the URL:
http://externalsite.com/app?param=value&otherparam=othervalue
Try using an indirect method. Create a FORM. Set its action parameter to the base url you want to navigate. Set its method to POST. Set its target to your iframe and then create the necessary parameters as hidden inputs. Finally, submit the form. It should work since it works with POST.

Drupal paths in themes

On certain pages drupal_get_path isn't working correctly (or it is and I've got the wrong function)
The base path is wrong
Example:
Image is supposed to be at
http://domain.com/sites/all/modules/pecapture/images/headline_dontmissout.jpg
But when on
http://domain.com/node/9
The URL is
http://domain.com/node/sites/all/modules/pecapture/images/headline_dontmissout.jpg
The same happens on the page
http://domain.com/admin/build/ and block edit page
How do I get the right path?
added base_path() to beginning of my paths...
base_path (http://api.drupal.org/api/base_path), if you use php code.
In html case, just add "/", like: /sites/all/modules/pecapture/images/headline_dontmissout.jpg
One problem: if you work on subfolder (Drupal installed in internal folder of main site): http://domain.com/subfoldersite, it will not correct, becase will remove "subfoldersite".

Resources