Solved

asp.net c# - A default document is not configured for the requested URL

Posted on 2014-11-10
4
400 Views
Last Modified: 2014-11-11
I am following an asp.net tutorial. I am getting errors (please see the attached image).

Question: Can I view this sample site without IIS? If so, please give me some direction to do this.

Thank you
IIS-Error.png
0
Comment
Question by:Mike Eghtebas
  • 2
  • 2
4 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40434534
First, you have posted this in the wrong topic area.

Second, the error indicates that you miss a default page to open, like index.html or default.html or -.asp
This you can add, or you can modify the list of default page names at the web server.

Third, IIS is the preferred server engine for running asp. I wouldn't recommend - indeed not during a tutorial experience - to use anything else.

/gustav
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40435068
Now, I am getting: "ExecuteReader: Connection property has not been initialized." at line 19 (SqlDataReader rdr = cmd.ExecuteReader();).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string cs = ConfigurationManager.ConnectionStrings["StudentDB"].ConnectionString;
        SqlConnection con = new SqlConnection(cs);
        SqlCommand cmd = new SqlCommand("Select ID, FirstName, LastName, Gender FROM Students WHERE Gender='Male'");
        List<Student> listStudents = new List<Student>();
        con.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            Student student = new Student();
            student.ID = Convert.ToInt32(rdr["ID"]);
            student.FirstName = rdr["FirstName"].ToString();
            student.LastName = rdr["LastName"].ToString();
            student.Gender = rdr["Gender"].ToString();

            listStudents.Add(student);
        }
        con.Close();
        GridView1.DataSource = listStudents;
        GridView1.DataBind();

    }
}
-------------------------
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  Data Source=USER-PC;Initial Catalog=ROD_July18;Integrated Security=True
  Data Source=.\SQLEXPRESS12;Initial Catalog=MME_Sample; Integrated Security=True
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="StudentDB" connectionString="Data Source=.\SQLEXPRESS12;Initial Catalog=MME_Sample; Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>

Open in new window

Sorry for the wrong TA.

re:> Third, IIS is the preferred server engine for running asp.

Once using IIS with vs2008, I had to activate IIS and I messed it. The problem was I didn't do SQL Server installation, vs installation, and IIS activation in the correct order. That is why I was trying to stay away from it.

But now, it seems with vs2010 or vs2012, it possibly configures and activates IIS automatically. Any comment on this will be greatly appreciated.

Mike
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40435146
Uh Mike, SqlCommand and the like is not my strong area. I always use the DataTableAdapters or other class wrappers with strong typing.

Perhaps you should add the ASP TA?

/gustav
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 40435160
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unrecognized Database Format 8 93
Auto Filter in Combo Box 7 33
How can I name a sub macro so Shift/F10 would work. 3 23
Access Query based on a Form Field 2 21
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now