Bytes and Bites of Internet
IIS
Use of SLL in IIS
Aug 12th
I recently got curious about use of SSL in SSRS. I mean I know that it has an option to use secure HTTP but I have never used it. Because in all of the places where I have worked were either not interested in using SSL or just felt that it is too expensive to use and maintain ‘em.
So this weekend I decided to take matters in my hand and decided to start my journey to make SSRS use SSL . And first step for me was to make IIS use SSL. I really don’t have expertise to explain how SSL works but it is basically process of exchanging information between server and client via certificates and then verifying that information to make sure that both server and client are really what they say that they are.
And as you know that these server certificates has to be signed by some kind of CA (certificate authorities) and they charge hefty amount of $$$ for these kind of certificates. But if you want to use your secure HTTP just for very limited userbase or want to test some SSL based features then IIS has a feature called “self-signed certificates” which basically allows users to create their own certificates to use !!
This whole process of generating self-signed certificate is very easy process. For that just open up IIS Manager and select “Server Certificates”. Open up that option and on right hand side there is a sidebar with bunch of different options. One of the option is “Create Self-Signed Certificate”, click on that option and it will open up a small window. This window will prompt to specify “user friendly” name for that certificate. And that it !! Once user friendly name is entered, it creates certificate for you … just like that …
Easy URL Rewrite in IIS
Jul 22nd
URL rewriting is a process of shortening URL of web pages and making them more user friendly. If you have been working with MVC then you probably already know what I am talking about. But what to do if your application is plain old Web application? Having user friendly URL really simplifies things for end users. Imagine a product URL for your company is http://someCompany/Products/list/ProductName.aspx , which is definitely not helpful to customer who is trying to reach to that product page directly (only way probably is to create a link on some page). But with help of URL Rewrite you can shorten this URL to http://someCompany/Products/ProductName a user friendly URL, isn’t it ? Besides having good lookin’ URL another advantage is it hides actual directory structure from outside world.
In this post I am going to show how easy it can be to use this great little module.
First, if you don’t have this module it can be downloaded from IIS website or using Web PI (if you have downloaded Web PI before then chances are you already have it). Once it is installed, you will see it in IIS Manager (see screenshot below)
Setting up SMTP server in Windows .. to use Gmail
May 26th
Email notification is one of the most common method to provide update to users for various system events be it task completion/failures, system issues, reports etc. I have to use email notification time to time for all of those items. Once biggest complain in windows for emails is it doesn’t allow you to use basic authentication. Which means that you can’t use external SMTP servers (say Google or Yahoo) for sending email from Windows, you will always have to have your OWN SMTP server like Exchange server or other 3rd party Software. But if you have IIS 6.0 (or 5.0 I think) installed in a system you can use a feature called “Virtual SMTP Server” which can be used as … any guess ?? … yup, A SMTP Server. Since it is a virtual one it doesn’t have all bells ‘n whistles of real servers but it gets job done. It is actually ideal for basic email notification purposes and that’s just what I need . In rest of the post I am using Virtual SMTP Server (using IIS) and SMTP server interchangeably but in reality both are very different.
I am using Windows Server 2008 R2, so these steps are for same OS but I am sure that this process is very similar in previous versions as well. All you have to do is to open up “Server Manager” and goto “Features” section. And click on “Add Feature” this will open up “Add Features Wizard”, from that list of all features select “SMTP Server”. As soon as you select that check box a message will popup about IIS, that it will install additional IIS components too (it is because this virtual smtp server is a feature of IIS). Let wizard install required components of SMTP server.
Next is configuration of SMTP server. In this step we configure that server to use Gmail’s SMTP server to send emails. For that open up IIS 6 Manager, you should see a node called “SMTP Virtual Server # 1” it is a virtual SMTP server created by default (which can be renamed/deleted). Right click on it and select “properties”.
First tab is “General” which can be used to enable logging for troubleshooting. If you want to setup access to SMTP server it can be done using second tab “Access”. In that tab, in “Access Control” section click on “Authentication”. Authentication can be applied using various method but I chose “Anonymous Access” because many windows utilities and MSFT programs doesn’t support basic authentication. And with Anonymous Access selected anyone with local access can use that server to send emails.
.NET Framework 4 and Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’ Error …
Nov 28th
So, day before yesterday I was working on some app. And I deployed it on my IIS (v7.5) server. The deployment process went very well without any sort of troubles. But when I tried to run that application from my web browser I got loads of error. And I found that the main error was something like this,
Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’
Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.
Description: An unhandled exception occurred during the execution of the current Web request. Review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.
With little googling, I found that I was not the first victim of this error !!! And after few clicks I finally found the reason and solution for this error.
The Reason: If you have installed IIS AFTER installing .NET Framework 4 (in my case) then it won’t get register with IIS and so when you run the app that is built on .NET v.4 by deploying it won’t work and will give you above mentioned error. And the solution is next.
IIS 7.5 + Multiple websites = troubles
Aug 29th
Today when I was trying to work on an ASP.NET application which I was saving on my “Default Web Site” in IIS, I was getting “unable to start debugging on the web server. the iis worker process for the launched url isnot working” error whenever I try to run & debug any application in my Visual Studio 2010. Even my old application which were stored in IIS very long time ago were throwing me same error!!! …. But if I try to access that application directly by typing its path in browser, I was able to run them properly !!! .. So I figured out that something must be wrong with my IIS (or its Settings ) but not with my application itself …
Accessing file in filestream using ASP.NET
Aug 10th
Like I posted last time, we can use cool feature of SQL Server called “File Stream” which practically allows user to store any kind of file. But as just like any other SQL syntax, it lacks UI to interact and also it really doesn’t have any use just sitting there in SQL Server. So, with that in mind, I thought to make an application which have atleast an understandable UI and some good feature that can leverage both SQL Server and .NET Framework.
So, with some “research” on Google, I finally was able to create an ASP.NET application which can be used to both read and write files in SQL Server using filestream. It basically accepts First Name, Last Name and path to document which is then passed to database. And in another part, same information is retrieved back in data grid from where user can simply click on link to download the file.
To make it Work …
to make my application, I have used IIS (I have not included web.config file as it only contains db login string). Which has access to my database for this test. But you should remember that SQL Server will not allow any other user (even IIS User have login with enough rights) , so DB connection must be using Windows Authentication (no SA !!) and also, you need to use impersonation for ASP application to access NTFS file system (which is used and hence managed by SQL Server for filestream) … it can be done from IIS –>application_Name->Authentication
Bulk Insert into SQL Server with ASP.NET …
Jul 29th
As title is self explanatory … lets image you have some web application (that maintains an inventory of goods for example), and one day you need to change price of goods you have due to any reason (tax hike or change in commission or simple b’coz of price raise … I am a developer not business man, so I can’t think of all genuine reasons ) … and so now you need to change price of all those goods … how you will do that ?? well, it can be done by manually changing price of each item, and its easy if you have only few items (but if this number is even >100 you will soon find your self typing lots) … or you can create a script which updates price of all stuffs all together … second approach is more feasible if you have higher number of items in inventory. But again this will need manual intervention + expertise in SQL (assuming your backend is SQL Server ofcourse ) … but there is 3rd approach, as a developer I have already included an upload feature in the application which can be used in this circumstance to bulk update the table and all you need is a csv or text file !!!
About test application, I am using ASP.NET (.NET framework 4), IIS 7.5 (I am using Window 7), and ofcourse SQL Server 2008 dev. edition … I won’t be explaining whole thing but I will write about major parts. I have created sample database in sql server,