Saturday, July 12, 2008
#
Suddenly for no apparent reason, one of our applications (after publishing) started giving this 404 error message:
Server Error in ‘/xxx’ Application.
—————————————————-
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested Url: /xx/xx.aspx
This error was coming on all pages in the application, I checked and re-checked ASP.NET version in IIS, read-write permissions on the published folder, application pool setting, trailing slash problem (http://support.microsoft.com/kb/894670/en) and every other thing, but none helped!
I did some googling but came up with same results, these are the links I checked:
http://cephas.net/blog/2005/07/14/aspnet-the-resource-cannot-be-found/
http://forums.asp.net/t/1186539.aspx
By chance I noticed this link: http://dotnet.org.za/armand/archive/2005/07/03/38757.aspx about removing app_oflline.htm file from the root directory.
And I realized that we too have the app_offline.htm file and the moment we removed it, the application worked like a charm!
Hope this helps others!
Wednesday, July 02, 2008
#
Which is better for scalable commercial applications: ASP.NET or PHP?
This question has been raised so many times with my different clients tempting me to know how other fellow programmers feel on this issue. This is what I think:
1. ASP.NET being object oriented is more "organized" and maintainable than scripted PHP. Besides being fully compiled, ASP.NET platform offers loads of pure OO features like inheritance, polymorphism, overloading etc. Newer versions of PHP support OOP but its very limited compared to ASP.NET.
2. Development in ASP.NET is becoming more and more faster thanks to integrated VS environment, great debugging support and a lot of out-of-the-box controls.
3. Framework Class Library (FCL) is a huge asset compared to PHPs libraries.
4. PHP is more hackable than ASP.NET.
5. PHP promotes messy code and has poor error handling capabilites.
6. ASP.NET offers more powerful features to control entire HTTP pipeline in its different stages using HttpModules and HttpHandlers.
7. ASP.NET offers different methods to store session data.
8. ASP.NET is more scalable than PHP.
9. ASP.NET is more faster than PHP.
10. ASP.NET will cost less in terms of hardware to support and scale an application.
I would like to know what others think ! Let me know if you think I am wrong somewhere! I have programmed in PHP years back and I know PHP too!
Saturday, April 26, 2008
#
Since last week we were getting this weird error when someone tried to post in our client applications forums:
The session identity provided has expired or could not be found.
This was a custom error which clearly meant that session has expired, but the strange thing was that every one was still logged on and after moving back and doing a refresh lets the post get through, without any error.
There was also another related error which was also due to sessions not getting expired after clicking LogOut button, in the event handler of which we had clearly expired session using Session.Abandon(). Session.RemoveALL() and god knows what all!
This problem took 2-3 days as we were trying to find out the reason in the code, but looked as if everything was perfect.
Then accidentally we noticed that Web garden had been enabled on the application in IIS!
We used this tool:
IISAPP: to find what PID to trace, and we noticed this:
W3WP.exe PID: 12408 AppPoolId: app.com(domain)(pool)
W3WP.exe PID: 4348 AppPoolId: app.com(domain)(pool)
W3WP.exe PID: 4736 AppPoolId: DefaultAppPool
We have two PID's for one pool! That clearly indicated that something is wrong with the way app had been set up, and we opened IIS MMC and noticed that web garden was indeed enabled, causing session to mix up!
We disabled it and the app was fine! Now all that needs to be done is to find the culprit who switched it on!
In the process I also learnt about
iisstate tool:
iistate -p PID -d -sc -hc > iisoutput.txt
This would then give me every .net temp file accessed every symbol loaded!
Monday, April 14, 2008
#
Just a small catch: My friend was using formsauthentication and for some weird reason he was not able to redirect to the requested page even after successful login. It was a simple mistake in his code:
if you have FormsAuthentication enabled and creating a persistent cookie based on Remember Me check box selection, you need to make sure that for the other case, where the user does not select the checkbox, the method should have false set as the second argument, if by mistake you have set it to true, then the page will not redirect and will reload the same login page.
/*
* Redirect to originally requested page,persistent cookie not selected
*/
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
Tuesday, April 01, 2008
#
Today was a lucky day for me, I got this wonderful email from my MVP lead that my MVP award has been renewed for another year!
I love this MVP program! It is a wonderful way to sharpen your knowledge, helping out in the community and get rewarded for the same!
Thursday, March 27, 2008
#
I think there is a bug in VS 2008 (Professional Edition). I installed it on another new machine and this time I did not install Visual Web Developer (as it was not required at all). Everything went fine with the installation and after rebooting the machine, I got the shock of my life: I could not create a Website!! The menu was simply not there under File option!
I tried using devenv /resetsettings but it did not work. The OS was exactly the same (WinXP Pro) like the other machine where 2008 worked fine. Then I asked myself, what was different in both the installations? Culprit was VWD! I added it again (using Add/Remove components from VS installer) and voila, it worked like a charm!
So I think this is a bug in VS 2008!
Tuesday, March 11, 2008
#
Since many people would agree with me that Windows Vista has a lot of problems for developers, the only option is to revert back to Windows XP Pro on all these new pre-installed Vista laptops. But 90% of the time, upgrading poses this stumper:
Setup did not find any hard disk drives installed in your computer
To fix this issue, we need to change the SATA/ RAID mode one and disable caching as shown here:
http://www.techspot.com/vb/topic18329.html
http://www.howtogeek.com/howto/windows/resolving-setup-did-not-find-any-hard-disk-drives-during-windows-xp-installation/
Monday, March 10, 2008
#
Recently I faced a strange issue: while working on a sample project in ASP.NET 2.0 and VS 2005(which just had one form loading records from a single table from a SQL Server 2005 DB), I face this error as soon as I form started loading in the browser:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
My form simply connects to the relevant table in the DB and tries to get the records, but the app throws up this googly of an error as soon as it tries to connect to the DB. I checked the connection string 3-4 times, changed user name and password, but still the same error. A real googly for me!
Then while checking the code at a breakpoint, I noticed that the connection string had this value:
"data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
I was stumped!! I did not install SQL Express and was not using the specified database mentioned in this "ghostly" connection string, all I had was a simple clean instance of SQL Server 2005 Enterprise edition!
I was sure this connection string was coming from some "higher" location, overriding my value, and then while searching google I came across this awesome post from Scott:
http://weblogs.asp.net/scottgu/archive/2006/11/20/common-gotcha-don-t-forget-to-clear-when-adding-providers.aspx
Though I was not using providers, using <clear/> fixed my issue! Here is the explanation:
By default ASP.NET 2.0 registers a set of default SQL Express providers within the root web.config file on your machine that create a SQL Express database within your /app_data directory to store/manage membership/role/profile data when you first access it. Because this is registered at the machine-wide level, all provider collections by default inherit this registration. Unless you explictly <clear/> or override the inherited value, your application will have this default membership/role/profile provider registered.
Because the above web.config file simply added a new provider -- and didn't clear or replace the default provider registration -- the above application now has two Membership providers configured. When you do a Membership.CreateUser() call in your code, ASP.NET will attempt to create the user in both membership databases. If you don't have SQL Express installed on your system, the create-user attempt will fail for this database - which leads to the errors and/or weird behavior above.
Now, I am not using Memership Providers, so I am confused as to why would this error occur in my case? Also, should not the application web.config override the machine.configs value?
Thursday, February 28, 2008
#
Two good articles on web deployment projects in ASP.NET 2.0:
http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx
http://msdn.microsoft.com/msdnmag/issues/07/04/ExtremeASPNET/default.aspx
Thursday, February 21, 2008
#
http://msdn2.microsoft.com/en-us/teamsystem/aa718948.aspx
"The Guidance Automation Extensions (GAX) expands the capabilities of Visual Studio by allowing architects and developers to run guidance packages, such as those included in Software Factories, which automate key development tasks from within the Visual Studio environment.
The Guidance Automation Toolkit (GAT) is an extension to Visual Studio that allows architects to author rich, integrated user experiences for reusable assets including frameworks, components and patterns. The resulting Guidance Packages are composed of templates, wizards and recipes, which help developers build solutions in a way consistent with the architecture guidance."
This will be immensely useful to make sure that the project "stays within the defined architectural limits" and will promote better programming and design in general!
Monday, February 18, 2008
#
This is a very common problem: a developer makes some GUI related changes, like modifying colors in stylesheets or uploading modified images, and then uploads changes to the remote web server (which can be for testing or even a live production server). But he/she is not able to view the changes, the web server shows old cached content! Welcome to IIS Caching!
IIS (and other web servers) generally handle and cache static content like stylesheets, image files (though we can by pass this process by letting ASP.NET runtime handle these files), and this is important for faster processing. But sometimes it adds to the delay in testing and implementing new design changes, and one simple way is to expire the server cache. Most of the time "Expire Content Cache" does not seem to work, and this post below explains very nicely why it does not work and what are the other effective options to expire the cache:
http://aspnetresources.com/blog/cache_control_extensions.aspx
So we can manually expire the cache by setting custom (and low) values for the pre-check and post-check values)!
Monday, February 11, 2008
#
We can localize Javascript pop up texts using server side variables in client side. In page class we will declare a protected variable:
public partial class _Default : BasePage
{
protected string jsPopUpText;
protected void Page_Load(object sender, EventArgs e)
{
jsPopUpText= Resources.TestSiteResources.jsPopUp;
}
Then we will use this value in the client side JS code as:
<script language="javascript">
alert('<%= jsPopUpText %>');
</script>
This will show us the localized text value from the RESX file based on the current thread's locale. For more info on localization in ASP.NET, refer this article:
http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx
Monday, February 04, 2008
#
Google has put up 10M$ for an android developer challenger:
http://code.google.com/android/adc.html
Android is google's SDK (C/C++ based) for mobile devices, more details: http://code.google.com/android/what-is-android.html. One interesting thing is that Android supports SQLLite, a relational DB engine!
Wednesday, January 23, 2008
#
A junior developer in our recent project got stuck in this issue: he had to call Javascript code from VB.NET code behind and insert this value in a function: Jammin' Hard.
Now the single quote (apostrophe ') was creating trouble, giving an error as JS string got terminated. A simple solution in such cases is to use HTML codes for apostrophe, which is : '
So the string should be passed as: Jammin' Hard
This solved his issue. See this table for more codes: http://www.netlingo.com/tags.cfm
Friday, January 18, 2008
#
Now we can debug the source code of .NET framework! This will really help in getting to the details of the libraries and developing a deeper understanding of things, and much less usage of the very famous Roeder's Reflector (www.aisto.com/roeder/dotnet/)
For more details: http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx