Solved

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

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

Author Closing Comment

by:Mike Eghtebas
ID: 40435160
Thank you.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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