Solved

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

Posted on 2014-11-10
4
375 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

21 Experts available now in Live!

Get 1:1 Help Now