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.
Related
In my web app I have a lot of gridviews and so on. Now I was trying to change some data format in the gridview, and the changes did not take effect when i debugged, either in Chrome nor Internet Explorer, it kept showing the same gridview as before. I tried to change the SQL data I was providing to it, and it actually changed, so the problem is when I'm altering in my web project.
Wondering what this could be, I did another test by removing the function that triggered when a button is pressed. When I debugged not only I did not get the error that usually comes with not assigning anything to a OnButtonClick but also when I pressed the button it did what it was doing before i removed the function.
Did this already happen to any of you?
Edit1. Now I tried to create an empty webform and when I debugged I get this error:
Error of analyzer
Description: Error parsing a resource required to make this request. See the
specific analysis error details below and modify your source file appropriately .
Are you hosting in IIS or debugging with Visual Studio's inbuilt server?
Try cleaning and rebuilding your code, then clearing your browser cache
Try deleting cache and cookies from (both of) your browsers.
Sometimes this gives problems when you are debugging because you will keep seeing previous parts of your current app.
I'm currently under the belief it may be to do with the header information but I'm really not too sure. The image on this page is the best example of it that I can give. It will display sometimes in a web browser control, and other times it just plain refuses to. Does anyone have any idea as to why?
The code I'm using to try and grab the image is simply:
WebBrowser.Navigate("http://www.lse.co.uk/tools/user/imgChatUsagePie.asp?nick=mulledwine", null, null, "image/gif");
It's really hard to ascertain as to what is causing the image to display sometimes and others not as it works completely fine within Chrome. Is this a problem related specifically to the web browser control?
Thank you in advance.
Apparently, the server side script checks the ASP Session ID cookie and displays the image depending on some session variable stored on the server.
Try navigating the to the HTML page first, then request that image.
Sometimes the data is a valid image, and sometimes it is not.
But seriously You need to give more information I assume you mean
http://www.lse.co.uk/tools/user/imgChatUsagePie.asp?nick=mulledwine
Maybe post the code you use to generate the image. Is this browser specific. Under what conditions does the pie chart fail to generate. Does the url give an error message when it refuses to display the image etc. I would assume some variable you use to generate the image is null and throws an unhandled exception causing the page to return 500 and some kind of error rather than image data.
If it is really just sometimes it works and sometimes it doesn't id recommend using some kind of test suit to keep requesting the image at random images until it fails and then isolate the error message. Selenium or Fiddler may be of some use to isolate the problem.
I need to display HTML in my silverlight application and cannot find a way of doing it. I cannot use the web browser control as it needs to be able to run in or out of a browser.
Does anyone know of a good way to do this, because all I can think of doing at the moment is running replace methods on the text to just replace the tags with C# equivalents eg(<br /> to \n).
The way I do it is to check if the application is running inside the browser and change the means of display accordingly. If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/book/downloadfile/4638.
Hope this helps...
Chris
I believe what you are looking for is HTML Bridge.
Edit I'm am actually now unsure if you'll still have access to javascript if you're running this OOB. I'm going to look into this some more and will further update. I'll still leave the answer up though for reference.
Second Edit Here is what I've found. HTML Bridge is disabled when you run silverlight out of browser. This disables access to the HTML DOM as well as Javascript. However, according to a comment on this site:
HTML Bridge is not available when you first install a OOB app. But you CAN force it if you modify the index.html in the folder where the app is installed just adding the enablehtmlaccess parameter.
It works!
You can even create dynamic HTML elements using the well-known methods of the HtmlPage class. You can even open a new browser window with the Navigate() method and its "_blank" parameter.
Keep in mind this information was posted about SL 3. Its possible that this may have changed, but I doubt it. So it seems that what you may want to do is build a script into the startup of your SL app that detects whether or not your app is running out of browser. If it is then you may want to have some script to call that can modify this file for you.
There recently was a similar question.
I posted a link there to an implementation that parses and displays HTML inline in Silverlight. Of course, it will work only with simple HTML, but maybe you can expand it to your needs.
I have an web based application. The content for the Home page has been currently mentioned in the HTML code for the Home page using , and tags. To change the content anytime in future, it needs to be changed in the HTML code. :(
Is there a way that we can pick up the content from some external place and get it reflected through the website. This ways, any change if required can be made at the external location without referring to the application's code.
Please advise if there is any solution for it.
Thanks.
You can
Use a database
Include external files using Server Side Includes
Read external files and write their contents and an alternative method
Sounds like you're looking for a Content Management System (CMS), which will allow your content editors access to modify only specific blocks of a page that you specify.
There are a ton out there to do what you want, so you don't have to start from scratch. Just Google 'CMS'.
Although I haven't used it myself, DotNetNuke is a popular one these days and has a free version.
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.