In order to give ASP.NET the permissions it needs to use Excel, you'll likely need to add the line <identity impersonate="true"/> to your web.config file or configure your app to run under an appropriate user account.

--
I hope this helps,
Steve C. Orr, MCSD
[url]http://Steve.Orr.net[/url]


"sudha" <sudha_smailcity.com> wrote in message news:00dc01c33f24$4c9128e0$a301280aphx.gbl...
> I am using excel object in my server side code. But, I am
> getting Access denied error for the user asp.net . I gave
> full permission for the Asp.net account on the directory
> where I am running the application.Do I need to change any
> security permission for excel?? Here is my code and the
> exception that I am getting.
>
> Excel.Application excel= new Excel.Application();
> int rowIndex=1;
> int colIndex=0;
>
> excel.Application.Workbooks.Add(true);
>
> DataSet dsSearch = DeserializeDataSource();
>
> DataTable table=dsSearch.Tables[0];
>
> foreach(DataColumn col in table.Columns)
> {
> colIndex++;
> excel.Cells[1,colIndex]=col.ColumnName;
>
> }
>
> foreach(DataRow row in table.Rows)
> {
> rowIndex++;
> colIndex=0;
> foreach(DataColumn col in table.Columns)
> {
> colIndex++;
> excel.Cells[rowIndex,colIndex]=row
> [col.ColumnName].ToString();
> }
> }
> excel.Visible=true;
>
> ERROR
> --------
> Access is denied.
> Description: An unhandled exception occurred during the
> execution of the current web request. Please review the
> stack trace for more information about the error and where
> it originated in the code.
>
> Exception Details: System.UnauthorizedAccesception:
> Access is denied.
>
> The ASP.NET process is not authorized to access the
> requested resource. For security reasons the default
> ASP.NET process identity is '{machinename}\ASPNET', which
> has limited privileges. Consider granting access rights to
> the resource to the ASP.NET process identity.
>
> To grant ASP.NET write access to a file, right-click the
> file in Explorer, choose "Properties" and select the
> Security tab. Click "Add" to add the "{machinename}
> \ASPNET" user. Highlight the ASP.NET account, and check
> the Write box in the Allow column.
>
> Source Error:
>
>
> Line 1161: {
> Line 1162:
> Line 1163:Excel.Application excel= new Excel.Application();
> Line 1164: int rowIndex=1;
> Line 1165: int colIndex=0;
>
>