Solved

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

Posted on 2014-11-10
4
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 50

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 34

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 50

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 34

Author Closing Comment

by:Mike Eghtebas
ID: 40435160
Thank you.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

732 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