IIS access to a variety of issues (vs access Normal) part of the processing methods in detail _ practical skills

Source: Internet
Author: User

Today, a friend asked me a question, the general meaning of the problem is to create a new project, in VS debugging can be normal, but in IIS access will be a variety of problems. I personally think that this problem is easy to solve, because the park friends and I away from the very far, only through the QQ video to operate, but I found this way of communication is really not very convenient. Simply put these questions in order, so it is easier to deal with the method to explain clearly.

Because my current project does not exist for this problem, so I can only create a new simple project, and then the local operation, try to let this problem appear, also because I have never sorted out the problem, now tidy up, and then I encountered some of the problems to organize, explain how to solve such problems. If you still have some problems, but I do not think now, then please leave a message to me, I will put these issues again to organize.

First of all, the first question, database access problems. I'm afraid this is the most common problem. Because this operation is very simple, detailed details I will not elaborate, we will understand at a glance.

First we created a new Web project, and added a page to the project called Test.aspx, which added a button that, when clicked, would connect the database to extract the data from the database and display it on the surface of the GridView.

Copy Code code as follows:

protected void Button1_Click (object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection (@ "Data source=.\sqlexpress;initial catalog=dblog;integrated Security=True");
SqlCommand cmd = conn. CreateCommand ();
Try
{
String sql = "SELECT top * from log";
SqlDataAdapter SDA = new SqlDataAdapter (SQL, conn);
DataTable dt = new DataTable ();
Sda. Fill (DT);

Gridview1.datasource = DT;
Gridview1.databind ();
}
catch (Exception ex)
{
String errmsg = ex. message;
Response.Write (ex. message);
}
}

If there is an exception to the connection database, we print out the exception information directly. Now let's look at the results.

The above diagram is the result of the F5 run through the VS, and obviously the results are correct, so let's take a look at the results shown under IIS. What, you don't know how to put it in IIS, so well, I'll briefly describe, create a new virtual directory or Web site in IIS, and then fill in the path of the project.

There was a problem accessing IIS that showed not the data in the database but the exception information displayed in the exception information. What's the reason? Look at the exception information prompts, open the database failed, this is why? From this reason we can consider several aspects.

    The configuration of the
      database, because this blog if you want to describe the configuration of the database, it will be very long, so a brief explanation, that is, in the database to set several of these places to enable general can be resolved.

2. If it is not a configuration problem for the database, it may cause the database password that we opened the database to be incorrect. This also needs to check, open the database server is correct, the database name is correct, because our experiment is through Windows authentication access, so there is no problem of password error.

3. Is the question of competence. This should be the main problem and it will make some people crazy. Actually, that's what we do when we do the project. Control user access is the same, the database prohibits this user access.

Since the issue of permissions, then we have to say that IIS running under which user? We log on to the operating system with the administrator of the Austrian, or there will be errors. In fact, IIS runs under a user named Iis_user, which may be different under the IIS version, network_services sometimes needed in IIS, but in IIS7 it is the user, Because I installed the IIS7. If we are using a Server 2003 system, you can set permissions directly on IIS. Because I am using Server 2003 in the company, so it is more clear.

First came up on the error. Due to insufficient authority, then we will give him additional privileges. Select the project folder, add the Iis_users user, and then give him specific permissions to be normal.

Maybe some friends to scold me, how did not see that database can not log on the error, I can only say sorry, because I did not simulate the error. Because I am using the Windows 7 system, in fact, in the presence of a configuration error, I expected that the database connection login error occurred. I'll take it out when I simulate the login error. However, you should be able to resolve all permissions errors by setting permissions.

To sum up , the problem of IIS login error is very basic, as long as we use the search engine, generally such problems are easy to solve. This podcast is common sense paste, know the words is very easy, but if can't find the reason, also very annoying, so put forward to share together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.