asp.net webpage defaultDocument button click not firing - asp.net

I have developed an asp.net website in VS2010. The defaultDocument is set to default.aspx in the root directory, as I have dome many times before.
For reasons unknown an asp:button in default.aspx is not firing correctly when the url is typed in without the file extension.
For example, if I type the url www.mywebsite.com the default.aspx page will load as expected, however, the button will not fire (it does postback but doesn't fire the server click event).
If i type in the url www.mywebsite.com/default.aspx it works as expected.
The problem I'm having only occurs in a live environment (I cannot recreate the error on the localhost).
Any idea's?

Sorted this out last night. It turned out it was an HttpModule of the Telerik web controls I use, in the web.config.
RadCompression... (or something similar). It compresses and cleans up code after an ajax response.
I have no idea why it was affecting the defaultDocument only, but removing it solved my problem.

Related

IIS Server files Updated, but it is not updated in web browser view source. Why?

I deployed the web application in asp.net, there's one file named default.aspx that contains one script(ex : alert('dfdf');).
I removed the script and deployed again. The deployed default.aspx file doesn't contain the script. But after I copied the default.aspx file in Inetpub/wwwroot and access the page through web browser and checked view source : the script is present.
But, in Inetpub/wwwroot/default.aspx doesn't contain any script. I refreshed and restarted my IIS server and my machine too.
May I know why this happen to me? Help me guys
Yes you have the page on browser cache.
If you use google chrome, open the browser tools, then keep the click on the reload button for 3 seconds and a menu opens to gives you some option, like "hard reload" means that it will load the page with out cache.
Other way is when you change some page press Shift + click on reload button this is usually force to reload the page even if its on cache.
All the shortcuts for diferent browsers:
https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache

Getting Page can't be displayed error after Response.Redirect on submit button click

I am getting a weird error on my asp.net web form page. I have a legacy page built up with full functionality. It has got several data controls on the page. After performing required operations when I click on submit button, internet explorer goes blank. It says page can't be displayed.
My code is old enough, so it actually works on few production sites. But recently I have deployed on a new production site. If I browse the same page using internal URL and perform same operation, it does not show any error message and everything works smoothly.
To give a background for the issue, when I click on submit button it calls web service on backend and comes back with web services result. Once it gets results back, it uses response.redirect() to same page (by creating url - Request.Url.AbsolutePath)with some additional parameters in querystring. If I refresh page then it shows same page correctly.
Page in IE -
Page in chrome -
Issue was not in code, but as I expected in production setup configuration. In production configuration a public URL something like www.test.com was redirected to www.test.com:7500. So when user was request website URL, it was being redirected to 7500 port on which application was hosted. It worked great until, response.redirect performed in asp.net code. When response.redirect performed in ASP.NET, in Request.Url.AbsolutePath server got URL as www.test.com:7500. So it tried to redirect it to 7500. But this redirection was set at public URL. When internally it tried to do the same it was not working.
I went with quick fix approach to fix this issue. I removed request redirection on public URL and set my site on port 80. This fixed my issue.
With out seeing the code it could be a number of things.
But as a guess I think that there maybe some url rewriting going on and then when the page posts back to its self it is not posting back to the rewritten page but to the underlining page.
You can try setting the form action to the rewritten page in the code behind.
form.action = "myrewrittenurl.com/path";
You can also try setting the form action to
<form action='#'
Which can work with some rewriters.

How to override page render for an error page?

We have an ASP.NET MVC application, and when it encounters an error you are not redirected to an erro rpage, instead the content of that page is replaced with the content of the error page. You go fix your code and press refresh and you're done.
We have another application that's written in WebForms and I'd like to get the same behavior out of it. Right now the current behavior is that when an error occurs you get redirected to ~/Error.aspx. Is it possible to make webforms behave this way? Perhaps override the page render event somehow?
This is just for development right? Displaying the error.aspx on production is much better both from a security and user experience perspective.
In order to turn off custom errors, you need to know how to turn them on. Yes? There are several places custom errors can be configured.
in IIS Create a Custom HTTP Error Response (IIS 7)
an error handler on the page, in global.asax, or in a class defined elsewhere (app_code folder perhaps)
in web.config Web.config customErrors mode
Web.config is probably the most common place. Start there.

how to remove default.aspx as default page from my application

I have changed Home.aspx to the default page but still when I run the app it is still going to default.aspx page. When I delete the default.aspx page and then I run it gives an exception that page not find (not 404 page not found). In some other page when I click on Grid row it should fire a grid row command but it calls default.aspx page first and then it fires the row command event. There is a connection between row command and default.aspx page, no response.redirect event from javascript but I don't know why it is calling DEFAULT.ASPX page.
Problem occurs only in IE
I have already set Home.aspx as default page but still it is searching for Default.aspx page at startup (Visual Studio).
If it is only problem in IE and works fine on other browsers, then consider clearing the cache of IE. Then do a hard refresh(CTRL+F5) of your web page.
Please recheck that you have mentioned the default document in web.config file.
If you are in hosting environment,then please select the default file from IIS setting for start pages from the control panel.
*If you have already tried right clicking the page and selecting Set as Startup Page , Did you checked in Visual studio site property pages, in start options list item there is "Start URL" and specific page properties. try changing these values ?
Did you checked if you are using built in asp.net URL routing or any other URL routing modules,handlers etc?
PS: if you are using web application project rather than web site project this setting is [yourapp]>properties>web>StartAction>StartURL
If you are using any javascript or jquery, please check that any default redirection (like ~/ or /) is there.

In ASP.NET which event fires when page is loaded in clients browers?

In ASP.NET which event fires when page is loaded in clients browers. Init, Load, PreRender event fires when page is not loaded in clients browser. Basically I have to some work when page is displayed in client's browser..
Instead of ASP.NET (server-side code) you might be more interested in Javascript (perhaps using jQuery's document.ready() which runs when the page has completed loading.)
Edit: The best answer I can come up with using only ASP.NET is OnLoadComplete()
There is no event like that. To understand why you have to understand how a web application works. The ASP.NET code runs on the server to build the contents of the web page, then the server sends the contents down to the browser which is running on the user's machine.
So the document being opened in the browser isn't even part of the ASP.NET page lifecycle. As far as ASP.NET is concerned, that page is now the browser's problem and it has already moved on to something else.
To make an analogy, it is like wanting to be notified when someone receives a letter that you (ASP.NET) mailed to them. Unless the recipient (the Browser) sends back some kind of communication there is no way for the sender (ASP.NET) to know what is happening somewhere else.
If you want to do something when the page is loaded in the browser, you need to write code that is run by the browser. Usually this is in the form of a script embedded in the page, usually in JavaScript.

Resources