I am creating a searching website using ASP.NET .On my one page I show URL of results.When I click on URL a new link is open but the URL path for the new link in the browser include loalhost:portnumbet.I do not want this in my URL.
For eg.
result
so on clicking result I go to browser where the URL is "https://localhost:8080//www.google.com"
why this localhost:8080 includes in the URL.
Thanks
When you are redirecting to the URL, you will not be adding any protocol information, so it will default to the current website/protocol.
For example;
Response.Redirect("www.google.com")
is not the same as;
Response.Redirect("http://www.google.com")
You need to add the fully qualified URL, otherwise it will believe it to berelative to the current website, therefore add the http(s):// to the redirect.
Related
My website is www.massasestefania.com.br
If you put the mouse over the link "Massas Estefania" on the end of the page you will see that the website is adding "www.massasestefania.com.br/" to the facebook address
My code is correct:
Massas Estefania
but the generated path is:
www.massasestefania.com.br/www.facebook.com/Massas-Estefania-1976106245948939/
Anyone to help me to fix it?
www.facebook.com/Massas-Estefania-1976106245948939/ is not a valid URL.
www.massasestefania.com.br is not a valid URL.
https://www.facebook.com/Massas-Estefania-1976106245948939/ is a valid URL.
http://www.massasestefania.com.br/ is a valid URL.
URLs must start either with https:// or http://. Browsers will always add anything else to the existing/current URL for the request.
The user has an option to enter hyperlinks which are persisted to the database, and then subsequently rendered to a Razor template. Where the user does not specify http://, however, the link is malformed; for example www.test.com renders as http://ourdomain.com/www.test.com.
How should we handle this?
The best thing to do is to run a regular expression on each hyperlink before you save it in the database. If it does not have http:// or https:// then I would just add http:// in front. All https sites will redirect http to https but most sites that do not support https won't smoothly redirect https to http.
An example of a possible regex is:
^(http|https)://
You want to be careful to only replace the http:// or https:// thats at the verify beginning of the string in case those values are used in url parameters
OK. Where to start....
I have a website. It is running on an IIS server using classic asp. I have forms on that website.
The forms were working fine until I decided to add some url rewrite rules to my web.config file to redirect nice looking urls.
After doing that, the form on my website does not post the data. It is going to the correct address, but nothing is passing to the page that is suppose to do the processing. On the page that I am processing if I do this:
For each FieldName in Request.Form
Response.write FieldName & " = " & Request.Form(FieldName) & "<br>"
Next
I get absolutely nothing. No form field names or values.
What do I need to add to the web.config file so that the data will post? And... more importantly... Where do I need to add it at in my web.config file?
Here is a text copy of my web.config file http://elvis-is-alive.com/webconfig.txt
Your web.config contains action=redirect.
A redirect always results redirect header being sent to the browser. This changes the URL in the browser address bar, and the browser then issues an HTTP GET for the new address. With an HTTP GET, no form/post data are ever sent; all arguments are assumed to be in the URL querystring.
If you'd like to avoid the redirect and use a true rewrite, change your web.config to use action=rewrite. Using this method, no redirect header is sent back to the browser, the browser address bar never changes, and IIS simply redirects the current request stream to a different location.
Something tells me that's not what you want-- you want the address bar in the browser to change and you want the form/post data to be preserved. This is not possible unless you do something very unusual, e.g. render a temporary interstitial page containing the original form/post request with an action pointing at the new URL. I don't recommend doing this.
Why not just change the form action in the original page's HTML?
I'm trying to create a web browser using Cocoa and Swift. I have an NSTextField where the user can enter the website he wants to open and a WebView where the page requested is displayed. So far, to improve the user experience, I'm checking if the website entered by the user starts with http:// and add it if it doesn't. Well, it works for most of the cases but not every time, for example when the user wants to open a local web page or something like about:blank. How can I check if adding http:// is necessary and if I should rather add https:// instead of http://?
You need to be more precise in your categorization of what the user typed in.
Here are some examples and expected reactions:
www.google.com: should be translated into http://www.google.com
ftp://www.foo.com: Should not be modified. Same goes to file:// (local)
Barrack Obama: Should probably run a search engine
about:settings: Should open an internal page
So after you figure out these rules with all their exceptions, you can use a regex to find out what should be done.
As for HTTP vs. HTTPS - if the site supports HTTPS, you'll get a redirect response (307 Internal Redirect, 301 Moved Permanently etc) if you go to the HTTP link. So for example, if you try to navigate to http://www.facebook.com, you'll receive a 307 that will redirect you to https://www.facebook.com. In other words, it's up to the site to tell the browser that it has HTTPS (unless of course you navigated to HTTPS to begin with).
A simple and fairly accurate approach would simply be to look for the presence of a different schema. If the string starts with [SomeText]: before any slashes are encountered, it is likely intended to indicate a different schema such as about:, mailto:, file: or ftp:.
If you do not see a non-http schema, try resolving the URL as an HTTP URL by prepending http://.
I have a web application that have many pages and folders, I want to make the URL to this website fixed for all pages, example: if the web site is
www.testwebsite.com/home.aspx when I redirect to login.aspx (for example) I want the URL to be
www.testwebsite.com/home.aspx without any changes and so on
Any suggestions ?
You can do a Server.Transfer, instead of Response.Redirect from home.aspx to login.aspx. This will keep the url as home.aspx
Response.Redirect : Tells the browser to go and visit another url. So there is a response coming back to browser and then browser is navigating to the new page. So its like a new request now. You will see the new page url in your address bar.
Server.Transfer : there will not be any "Redirect" response coming back to browser. The Server itself change the destination page. So the client browser does not know that its another page. So the url will not be changed.The Transfer method preserves the QueryString and Form collections.