no idea where to start on this one, but here goes. if i've missed an answer somewhere is becuase i don't know how to search for the error.
take a aspx page i.e. www.example.com/about when testing i have found (accidently i must say) that adding /anything i.e. www.example.com/about/eduhdbbw still returns the www.example.com/about page (assuming www.example.com/about/eduhdbbw doesn't exist). i would expect a 404 in this situation but i don't really know how it is routing to the original page.
fyi i'm using VS 2017 community with iis and asp.net webforms with c# and the error occurs in vs and compiled in iis. if any other info is needed please ask.
Edit: the about page does indeed show .aspx in the browser url. Also i am using a blank webform template, so it didn't come with anything pre-installed and i've not written and url re-write.
Pathinfo sound like it might be something but would this affect a project with just basic aspx and code behind, amd basically no other dependancy?
Also for now i am just using absolutepath to compare the page name and sending to 404 if it doesn't math; but it seems like a sloppy solution to have on every page...
Related
Right now i have a folder with another folder inside of it. The two folder names are called "pc details" and "pchardwaredetails"
When on a page in "pchardwaredetails" i want to return to a page in "pc details" using a button and response.redirect() but the file paths are just getting too complicated for me. What might the file path be from a page called "Details" in "pchardwaredetails" to a page called "viewMore" in "pc details"?
Also please feel free to explain how paths work so i know for future
thanks
Usually the Referrer of the page (a HTTP header), tells you what page you've come from so to go back you should just be able to do:
Response.Redirect(Request.UrlReferrer.ToString());
That's assuming you came from PC Details. However if you land on PC Hardware Details from some other page then that won't work, you would have to hard code the back feature.
You can simplify ASP.NET paths and use ~, for example:
Response.Redirect("~/some/path/pc_details.aspx");
I have the following problem. My C# application makes use of a webrequest and reades the html code of a url in order to do a bunch of things later on. While everything works fine, there are some websites that when visited they redirect you to another website (http://something.com/disclamer) for example and after you click yes you go back to the original website.
When I run my app it always only checks the html code of the disclaimer page and never gets to the actual page I asked for. I cannot really find a solution at this point since I can't find anything useful in the short html code of the disclaimer site (that comes before the one I want to check).
Any ideas on how I can skip that and take the code for the website I am actually interested in? Please note that I can't find any html redirection code indication (META HTTP-EQUIV etc) in any of the two websites.
Thank you
You can check the StatusCode to decide if you have been redirected. Status codes of 30x will tell you that you've been redirected, in which case you'll need to follow the link in the redirect.
http://msdn.microsoft.com/en-GB/library/system.net.httpwebresponse.statuscode.aspx
I believe you have to analyse the HTML code of such a page with a disclaimer to know which method is used there to make a redirect. Each case can be different: it can be either client-side or server-side redirection. If this disclaimer button submits a form, you will need to make a POST request imitating a button click.
Can someone see the code-behind of an .aspx website from a browser?
I have been told it is possible but i cant really find a way of doing it , viewing the page source only shows the presentation page..
So is there a way of doing it ? and how?
thank you
No, it is not possible to see the codebehind without physical or remote access to the server itself.
You could also in theory misconfigure the IIS server to display the source files, and that would cause them to be displayed, rather than compiled, but no idea why anyone would do that. IIS by default will not display them.
By default, IIS shows parts of your code (aspx or code-behind) when an exception occurs - along with the call stack of the exception. Any serious ASP.NET application hides this information from users by using specific error handlers to show the error information in another (often more user-friendly) format.
As others mentioned, it's not normally possible to see the code, as it's a server-side handler, compiled and run on the server, while client only sees the HTML output.
I am using the Tiny slideshow in my asp.net page. It works fine in all the Browser and here is the LINK, But my problem starts when I include that page in my master page and display the same. the Jquery stop working in Internet explorer.
http://www.spareach.com/public/xtemp8.aspx?userid=22&AspxAutoDetectCookieSupport=1
I am tired a lot for this.
Can any one help me please.
your script interpreted by ASP.NET Session. the actual URL of file is http://www.spareach.com/lightbox3/script.js. if you put the absolute URL then they work fine. hope this helpful
If you include that in another page, your relative link to the .js file is going to be invalid. So, your options are to make it absolute (http://www.something.com/folder/tiny.js) or to include the .js from the head or common document, if you use that structure.
I am working on a website that I inherited (ASP.NET and C#), and I noticed that in almost EVERY method in the code behind of the project pages (except some helper methods), the original author uses Response.Redirect() to redirect to a page (typically home.aspx, but not always).
What is the purpose of doing this? It seems unneeded to me - at least it doesn't appear to change anything the website is doing if I keep it in or remove it.
Thanks.
Response.Redirect() issues a 302 HTTP Redirect header to the browser, which causes the browser to request a new page from your web site.
If the author was using the POST-Redirect-GET pattern to stop the problem with users being able to hit the "refresh" button and repost forms, this might explain why it's used everywhere.
Redirects should really only be used when location is determined by something in the code behind. Redirects tend to cause ThreadAbortExceptions which are just further demand on a system when a simple href might be what the doctor ordered. Unless you can define some true architectural need for redirects, you might just want to begin phasing these things out.
It sends a response to the user agent/browser and tells it to redirect to the specified page. It can be put into any part of the code, but by default, the page will still execute to completion, then the redirect response will be set to the client...
It should only be needed at the last point in the code that you are running (generally)
ASP.NET Pages Post back to themselves, so some use the redirect method to open a new page. Use it when you need it. If you don't see a difference when you remove it. It might be the site uses links to navigate from one page to another, instead of doing it via the server.
Without more information it's hard to be definitive.
However, if home.aspx is an empty page, it may be that the original author may have been trying to terminate the processing of the page early in an effort to prevent subsequent processing.
Normally, Response.Redirect() is used to end the response and inform the browser to navigate to a new page. However, if the browser has that page cached, it may not actually perform a trip to the server. I've seen some cases where developers do this as a way of short-circuiting subsequent processing.
It's also possible that the code is doing something crazy, like making home.aspx the main display page for all data - and using session state or cache to communicate changes across pages. Sadly, I've seen this done too.... sigh. Often this is done to deal with the user being able to multiply submit forms.