Thursday, 3 October 2013

Error While using MySQL Database in Asp.Net

One day I tried to use MySQL database in my Asp.Net web application and when I finished all and uploaded files on server and typed URL in address bar to show the webpage function then I got an error that "MySql name space is not available, you are missing assembly reference". some thing like this.
You my face such problem while doing this even you have uploaded all dll files in bin folder of your web application.
The solution of such type of problem is that you should upload all contents of 'Bin' in root. Suppose you have all web pages and dll files in bin folder in  folder named 'My_First_MySql_application' and uploaded this in server then you will get above error. I would like to suggest you to upload your bin folder in root not in folder named 'My_First_MySql_application' also you should not keep bin folder in folder named 'My_First_MySql_application'.

Tuesday, 1 October 2013

URl Rewriting in

How to write SEO or user friendly URL in

You can get complete reference regarding URL Rewriting in Asp. Net from MSDN site.
actually URL rewriting means making URL user friendly so that every one can easily remember this.
suppose you want to redirect user from grid view to complete detail page then you will use redirect query string then your URL would be something like this. but you want to make it like this
to do this follow these simple steps.
1. make a page name it FirstPage.aspx . and second page SecondPage.aspx
2. take a global.asax file and import name space System.Web.Routing in it.
3. make a database and enter some detail in it regarding name, sex, phone no, emp_id, and other information of several persons so that we can display them in grid view of both pages. FirstPage will contain only ID and name while SecondPage will contain full detail of employee.
when some one clicks on ID of person on FirstPage it will redirect it to SecondPage with full detail of corresponding person with user friendly URL or re written URL.
here in my code you get a method shashiurl() method with anchor tag passing two parameters to get corresponding value of name and id of a particular person. see the image.
 now in the code behind we add this method with following details (Do not forget to include Routing namespace in every pages)
 here i am passing two parameter to GetRoutUrl method which is title and id related to particular table of person and here urldatail1 is name of route which will configure in Global.asax file.
Now come to Global.asax file and write according as:
 Now in the second page, You will have to display data according to id or primary received from Firstpage.aspx. so make page according to your requirement here i am using Grid view to display data. and code behind code is as:
Here we will have to capture Route Data value so that when ever we get related URL web page can retrieve information form server.
And in code behind file customErrors mode="Off" do not forget to include it.