Today I'm gonna give You (not show 'How to') an example of ASP.NET data-entry form. Even if You're an desktop-application expert, sometimes there's a need to build an application to communicate with database and consider multi-system environment (Linux, Windows, Mac, ..). ASP.NET gives You the ability to communicate with work-database no matter which system is used. Because it is considered as a web technology, the application works on IIS server somewhere in the Internet or local Intranet. It is convenient because there's no need to run from one pc to another and install any executable-type files.
Consider particular situation - Your company organises recruiting process. People send thousands of application documents. Your boss organises a group of people to go through all documents, choose a number of satisfying offers and put them into local database. You have to create an application for them and You still have in mind that they work on different operating systems. You must build a web-application, like this:
1. You have created Your ASP.NET app - You run it on built-in ASP.NET server and it works. How to put Your project on real IIS server?
1.1 Is there a IIS server on my machine?
There's possibilty that You already worked with IIS in the past but You can't remember now. If You did, You have Your IIS already installed and You are able to run it:
If You're not able to just click 'Play' (black right arrow) go to Your Services and try to run two of them - one is named something "Publish.. World Wide Web" (sorry I've got Xp PL) and the second is admin service of IIS and its name is located somewhere among upper services names (I've got "Administrator of IIS program").
Then You will see that You've got port :80 opened (netstat -an) and it is sign that Your IIS server now is working.
1.2 What if You don't have IIS installed - there's a lot about in the Internet - example hyperlink.
1.3 What are ways to deploy ASP.NET apps?
1.3.1 You can create a new Virtual Directory in IIS managment Window and just copy all project files there - it is not recommended, because not all project files are necessary to run Your web application.
1.3.2 You can use XCopy capability.
1.3.3 There's Visual Studio 2005 capability to provide Your application, feature is named Copy Web Site (Solution Explorer window)
1.3.4 I use Publish "project_name" method from project\Build menu:
1.3.5 You can also create web-app-installer just like in common executable case - just add new project to the Solution:
1.4 Little about IIS configuration - what if Your web app does not want to work?
1.4.1 First go to "eventvwr /s"
Search icons with yellow triangular related to w3svc source title (at least in my system it is connected with my IIS and asp.net configuration) - read error message and try to find some information related to the problem in msdn documentation.
1.4.2 Maybe You will need to register ASP.NET environment in the context of IIS service - how to? Go to the Windows\Microsoft.NET\Framework\framework_version (I choosed 2.X) and find:
Run cmd and type aspnet_regiis.exe -i
Why did I choose 2.X framework version? In a minute all will be clear.
1.4.3 You have the ability to choose framework version under which Your app is going to be run. How? Just right click in the name of Your newly created Virtual Directory, choose Properties and ASP.NET tab - I choosed 2.X.
1.4.4 There's more important thing about above Properties window - actually MAPPING CONFIGURATION in Virtual Directory tab. It is important to let Your system and IIS know which file is responsible for running ASP.NET apps - that's why You have to map *.aspx file to executable file (You tell Your system - Run aspx files by this particular executable like open txt documents in notepad or pdfs in Foxit). Click "Configuration" and check if aspx files are mapped to any executable:
1.4.5 One or two more things about msdtc - The Microsoft Distributed Transaction Coordinator (MS DTC) and IIS packages When Your database web application still doesn't work You may have to reinstall this Microsoft database transaction manager (msdtc) and create IIS packages once again - how?
You can find more about here.
2. How can I in programmatic way move from one aspx form (page) to another?
You can use Server.Transfer("form.aspx") method or Response.Redirect("form.aspx") method.
- // Programmatic Redirection - 293
- Server.Transfer("Form.aspx?login=" + this.LoginTextBox.Text);
- } // end of the Page_Load method
3. How can I send additional information through aspx forms?
Look above, the code includes additional info that was put inside the URL: ?param=value - but how to manage this information later?
- protected void Page_Load(object sender, EventArgs e)
- if (System.String.IsNullOrEmpty(Request.QueryString.ToString()))
- System.Web.Configuration.HttpRuntimeSection hrs = new System.Web.Configuration.HttpRuntimeSection();
- hrs.MaxRequestLength = 8192;
- this.UserNameLabel.Text = (Request.QueryString.ToString()).Remove(0, ("login=").Length);
In this particular way I provided login name from URL - I used Request.QueryString method.
(Soon I'll provide more description with FAQ about ASP.NET in the context of this project)