You are currently browsing the category archive for the ‘IIS and Crystal Reports and .Net’ category.

Error = The web server is configured to not list the content of this directory

I assume the environment to be  Windows 7 Professional, IIS 7. something. This error is caused when the directory browsing feature is disabled and or the default page is not properly set.  To sort out this issue go to IIS Manager. Open Directory Browsing.

Directory Browsing in IIS 7

Now click Enable from the options available on the right side. Restart IIS. Right Click on the App in the Default Websites tree. Click Manage Application , than Browse and Wala. The site will automatically start working. If there is still problems, check the default pages. if you have a default page other than the pages listed in the default page list. Add ur default page and check again. Site will be working.

I encountered this error while i was creating charts in asp.net using C#. The charts used to work fine in visual studio but when i published the website and tried to access the site through localhost (http://localhost/mysite/charts.aspx) it gave me this error. I’ll cut the crap and come straight to the point. The error was caused because ASP.NET machine user have no write permissions where my charts control wanted to create images.  I am using windows xp. I was looking for a way to give write permission to asp.net machine user on the charts folder in my website but there were no such options available in xp. To enable these option go to “tools” than to “folder options”  than click on the “view” tab. Now scroll down and uncheck “use simple file sharing”.

Uncheck "Use simple file sharing"

After this right click on ur charts folder where the images are supposed to be saved. Click on properties. Click on security tab. Add ASP.NET machine account user and give full rights.

Add ASP.NET mahine account user and give full rights

Click ok and check your published website charts. It will work fine. The next problem that I encountered was when I was trying to publish the same website on our Server machine running Windows Server 2003 to make it accessable through live ip. I repeated the above process and gave “ASP.NET machine account” user full rights but still the charts didn’t worked. The problem was solved by giving “Users” account write permission in addition to the ASP.NET machine user account on the charts folder on the server machine.

Sending emails through ASP.Net2.0  is very easy. Just a few lines of code. But when u get an error you will be surprised.  So before you write up the few lines of code you have to do the following.

Configure IIS for sending emails. Its simple not a big deal. Check if SMPT is already installed. If not installed than go to Add Remove Windows Components and double click IIS. Click SMTP. Install it and restart your system.  Now your local web server is ready for sending emails. The next thing is the coding part.

Add this line of code to the top of the page.

using System.Net.Mail;

To send an email you need the following parts of an email.

From (address who is sending the email)

To (to whom the emails is being sent)

Subject  (subject of the email)

Body (body text of the email)

Write the following code


string strFrom, strTo, strSubject, strBody;

strFrom = "sender@gmail.com";

strTo = "rece<a href="mailto:receiver@gmail.com">iver@gmail.com</a>";

strSubject = "Test Email";

strBody = "You have a test email.";

MailMessage eProEmail = new MailMessage(strFrom, strTo, strSubject, strBody);

SmtpClient emailClient = new SmtpClient("localhost");

emailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

emailClient.Send(eProEmail);

emailClient.Timeout = 500;

Run the code and check your email. I hope you will not encounter those errors saying “Mailbox not found” etc etc.

Before I can proceed with this tutorial I assume that the reader has already developed a report in crystal and has loaded it in crystal report viewer control. Running the website and the report page prompts the user with something like this.

Crystalreports Login Prompt

Crystalreports Login Prompt

Now we don’t want to give login information every time we try to run this report.  Its annoying . so what we need to do is to do something with the help of which we can get our report perfectly without this stupid prompt. To solve this problem we will provide the login information programmatically so that our report page don’t prompt us for it. To solve the problem I have done the following. Add the following code to the top of the report page.


using CrystalDecisions;

using CrystalDecisions.CrystalReports;

usingCrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

Now in the Page_Load()  event write the following code. Or we can write this code in any other function and call it when we want to provide the login information.

 

Now in the Page_Load()  event write the following code. Or we can write this code in any other function and call it when we want to provide the login information.


ReportDocument rpt = new ReportDocument();

rpt.Load(Server.MapPath("myReport.rpt"));

rpt.SetDatabaseLogon("myUserLogin", "mypassword", @"Server", "Database");

CrystalReportViewer1.ReportSource = rpt;

Save the page and run the report. This time it will not prompt for the stupid logon information. If some one wants a very basic article on how to create a report and how to call it in asp.net. plz leave your comments . I will write a basic tutorial for creating a crystal report and calling it from asp.net.

Note:- Plz  leave ur comments if this article was helpful.

Thanks.

 

Before I start I would like to tell all that I am using  visual studio 2005, dotnet framework 2.0 , windows xp sp 2 and IIS 5.1 with sqlserver 2008. I developed a web application and I wanted to make it available online on our server. The first thing that I did was to publish the web site, the path for the published files was c:\eprocure.  That went pretty well no error, and visual studio message was “published successfully”. The next thing was to make the published website accessible through the local server.  I created a virtual folder named “epro” for my published web application.  Than I tried to access the login.aspx page as  http://localhost/epro/login.aspx  and BANG the following error came out of no where

A name was started with an invalid character. Error processing resource ‘http://localhost/epro/&#8217;. Line 1, Posi…

<%@ Page Language=”C#” MasterPageFile=”~/Master.master” AutoEventWireup…

I tried a lot of tweaking , messed up a lot of thing but nothing worked. Finally the problem was solved as follows Type “cmd” in RUN. Go the following location.

D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

Look for a file

aspnet_regiis.exe.

When multiple versions of the .NET Framework are executing side-by-side on a single computer, the ASP.NET ISAPI version mapped to an ASP.NET application determines which version of the common language runtime (CLR) is used for the application. The ASP.NET IIS Registration Tool (Aspnet_regiis.exe) allows an administrator or installation program to easily update the script maps for an ASP.NET application to point to the ASP.NET ISAPI version that is associated with the tool. The tool can also be used to display the status of all installed versions of ASP. NET, register the ASP.NET version that is coupled with the tool, create client-script directories, and perform other configuration operations.

Execute the following command

 aspnet_regiis.exe-i.

this command installs the version of ASP.NET that is associated with Aspnet_regiis.exe and updates the script maps at the IIS metabase root and below. Only the script maps for applications that use an earlier version of ASP.NET are updated. Applications that use a later version are not affected.

Than execute the following command

aspnet_regiis.exe-e

this command removes the client-side scripts for ASP.NET from the aspnet_client subdirectory of each IIS site directory. Only the client-side scripts for the ASP.NET version associated with Aspnet_regiis.exe are removed.

Restart the system and check the website as http://localhost/epro/login.aspx and  the site is functional.

Please leave your comments if this helps.

Blog Stats

  • 325,597 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 233 other followers

%d bloggers like this: