Posts Tagged ‘ASP.NET 2.0’
ASP.NET Fileupload
Call me lazy cuz I am deserved it. It shocked me a bit when a production code crash on my face. As part of my job today I have to train a few admin staffs on how to operate our newly invented site www.ncdd.gov.kh/jobs it works out quiet well on my machine cuz I dev, test & teach on Mozill Firefox. But it turn out that I don’t perform enough exercise cuz I haven’t test the site with IE yeah, cuz I haven’t use IE for almost 3 years enough to forgot about it :)) anyway here is the story.
Do you know this guy System.Web.HttpPostedFile? yeah, he is my best friend when it comes to uploading file in ASP.NET. However you should know that he acted bit strange with browse in used.
Let say file1 is an instance of HttpPostedFile and if we ask him file1.FileName
Firefox return :
“Hello My Friend.doc“
Nice , isn’t it?IE return :
“C:\Document & Setting ….\user_name\desktop\Hello My Friend.doc“
WWOWO WHAT?! it slap me so hard to make me laugh out loud :))
Not Nice !
Anyway quick fix would be add a small detection on the file1.FileName
int lastDirSeparatorChar = file1.FileName.LastIndexOf(Path.DirectorySeparatorChar);
if (lastDirSeparatorChar > 0) {
filename = file1.FileName.Substring(lastDirSeparatorChar + 1);
} else {
filename = file1.FileName
}
Lesson learn – test dev. site with IE as much as I hate “IE”
Debugging failed because integrated Windows authentication is not enabled
On of the annoying error message while trying to debug my ASP.NET application.
The fact, I just did a clean install my machine (winxp) and manually create virtual directory from IIS and epected it just work, but no I need to perform a few additional step to make thing work.
Enable Integrated Windows Authentication on the local IIS
- Open IIS Manager (Internbet Information Services)
- Right-click the web site (in case you run it locally you only have Default web site) and pick Properties
- Choose “Directory Security” tab and click Edit on “Anonymous access and authentication control“
- In the opening window, uncheck “Allow Anonymous access” and check “Integrated Windows Authentication” (allowing anonymous can make that you don’t have enough permissions to debug)
Hope I don’t forget it again ;)
