Link to home
Start Free TrialLog in
Avatar of toooki
toooki

asked on

ASP.NET code error after deployment

I have a ASP.NET web application written in C# . It compiles on VS2008 and webpage comes up on the localhost url. works perfectly.

But I get error when I deploy to the location where I intend to deploy. Even when I try deployment on IIS of my local PC -- I get this error. So I am now clueless.

I try to connect to Oracle database. The web.cofig has the connection string.
web.config has this line:
    <add key="MyConnectString" value="Data Source=MY-DT-TESTDB;Persist Security Info=True;User ID=my_act;Password=myact4T;"/>

The "MY-DT-TESTDB" is in the tnsnames.ora file. No issue with login as it compiles and comes up when I run it on VS2008..

I get attached error when I deploy the application at :
C:\Inetpub\wwwroot\PDM\
The deployment succeeds and the URL:
http://localhost/PDM/ExcelUpload.aspx comes up -- no error. but the submit button when pressed gives error -- as it tries to connect to the Oracle database.

I am too far from my actual problem and it is a very small application ..
Many thanks in advance.

Avatar of Amro Osama
Amro Osama
Flag of Egypt image

could you copy/paste the error details?
Avatar of toooki
toooki

ASKER

Thanks. I have attached the screenshot.
 User generated image
try disabling the firewall and see if that helps.
Avatar of toooki

ASKER

It seems windows firewall is already turned off.
Attached screenshot.
untitled.JPG
Avatar of toooki

ASKER

I tried with a simplest code...attached.
And web.config has this:
      <appSettings>
      
          <add key="MyConnectString" value="Data Source=MY-DT-TESTDB;Persist Security Info=True;User ID=my_act;Password=myact4T;"/>
</appSettings>

I get error when I access web after deploying to
C:\Inetpub\wwwroot\PDPM\
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    

                            
        <asp:DropDownList ID="dd1" runat="server" 
        DataSourceID="SqlDataSource1" DataTextField="BRANCH_NAME" 
                                        DataValueField="BRANCH_NAME" 
        
            onselectedindexchanged="dd1_SelectedIndexChanged">
        </asp:DropDownList>
        
                                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                               ConnectionString="<%$ appSettings:MyConnectString %>" 
                               ProviderName= "System.Data.OracleClient"
                                 
                                SelectCommand="SELECT &quot;BRANCH_NAME&quot; FROM &quot;MYtab&quot;">
                            </asp:SqlDataSource>
        
        <br />
                            
    </div>
    </form>
</body>
</html>

Open in new window

untitled.JPG
ASKER CERTIFIED SOLUTION
Avatar of Amro Osama
Amro Osama
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of toooki

ASKER

Thank you.
It seems it is not even related to the database. I get the error even with a test page that has only one line of text or so. It compiles on the PC as expected but it gives error when deployed.
Build succeeds. Publish succeeds. But when I open up the page at the published URL I get the attached error.
The page comes up without issue on the localhost. The page content is attached.
Identical other page with changes in the file name comes up ok at the url. Problem seems to happen with new file I try to deploy. Clueless ..  User generated image
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MainMaster.Master" AutoEventWireup="true" CodeBehind="t1.aspx.cs" Inherits="PDMWebSln.t1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">\
        <div class="post-bgtop">
						<div class="post-bgbtm">
							<h2 class="title"><a href="#">Lorem Ipsum Dolor Volutpat</a></h2>
							<p class="byline">Posted by <a href="#">Someone</a> April 22, 2010</p>

							<div class="entry">
								<p>This is <strong>Vertebrate </strong>, a free, fully standards-compliant CSS template designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>. The slideshow uses photos from <a href="http://www.pdphoto.org">PDPhoto.org</a> and is powered by Slidertron (a jQuery plugin by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a>). This free template is released under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attributions</a> license, so you’re pretty much free to do whatever you want with it  (even use it commercially) provided you keep the links in the footer  intact. Aside from that, have fun with it :)</p>

							</div>
							<div class="meta">
								<p><a href="#" class="more">View More</a></p>
							</div>
						</div>
					</div>
</asp:Content>

Open in new window

it's strange allright, no clue actually.

are you sure your application is set to run on framework 4?, because from the screenshot the application is set to run on a Pool for .Net 4
Avatar of toooki

ASKER

Thank you.
I re-published. But still I get an error but not sure how to check or change the correct framework for what I am compiling and what is needed at the deployment server end.
I have attached the error screen that I get after the last publish.
Thanks a lot. User generated image
Avatar of toooki

ASKER

This is the part of the web.config file.
<compilation debug="true">
      <assemblies>
        <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C6661934E666"/>
        <!--<add assembly="Infragistics2.WebUI.UltraWebChart.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7PP5C3163F2CD0CB"/>-->
        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F6F7F11D66A3A"/>
        <!--<add assembly="Infragistics2.WebUI.Shared.v7.1, Version=7.1.20071.40, Culture=neutral, PublicKeyToken=7JJ5C3663F2CD0CB"/>-->
        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C555534E089"/>
        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD555E35"/>
        <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD777E35"/>
      </assemblies>
    </compilation>

Open in new window

hmmm, OK, from the screenshot i can see that the application is published under the .NET 4.0 Application Pool
and from the Web.config, the Assemblies are from .NET 2.0

that's causing the problem you are seeing.
you can fix this through one of the following:
1- change the target framework for the website to be 4.0
(not recommended, because you already have based your website on 2.0, and changing it most likely will cause you some troubles.

2-(recommended) change the application pool of the Published website under IIS to run in .NET 2.0 Application pool:
-Open Internet Information Services Manager (IIS)
-Expand the PC Node
-Expand the Sites Node
-Expand the Default Web Site
-Click on your Website Node
-On the Actions Pane, click on Basic Settings
-Click on the Select Button to change the Application Pool from
"ASP.NET v4.0"
To
"DefaultAppPool", but make sure it writes .NET Framework Version: 2.0
OK, OK that's it

you may need to restart the IIS Server, Click on the PC Node, and on the Actions Pane, Click Restart.

goodluck
Avatar of toooki

ASKER

Thanks a lot. I followed what you said but still I am getting the same error.

I did what you said (2nd option):
change the application pool of the Published website under IIS to run in .NET 2.0 Application pool:
-Open Internet Information Services Manager (IIS)
-Expand the PC Node
-Expand the Sites Node
-Expand the Default Web Site
-Click on your Website Node
-On the Actions Pane, click on Basic Settings
-Click on the Select Button to change the Application Pool from

It is already showing:
ASP.NET version: 2.0.50727
Virtual path: /PDM
File location: D:\mycode\..\PDPM\web.config

I have no control on the server on which I am trying to publish.

At the bottom of the error page it shows:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Is the above saying about the version of my PC's application (PC on which I am compiling and testing my code) or about the server on which I am trying to publish?

Thanks
it should be saying the one that the Instance is running, not what the application is set to run on.

because if you take a look at the web.config, your assemblies show v2.0.
try the Classic application pool, and maybe restart the PC
Avatar of toooki

ASKER

Thank you.

The bottom part of the above attached error page is:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

So I am compiling somehow in .NET Framework 4.0.

I do not have control on the server on which I am deploying. I confirmed that the deployment location is set for VisualStudio 2008 (.NET Framework 2.0).

Everything was working for me (including deployment) even few days ago.

I got rid of everything under
 <assemblies>
      </assemblies>

In web.config file. I know I used the same web.config file and that consistently worked before. And got confirmation that nothing changed in the deployment server.

How else could I set my application for .NET framework 2.0 ?
Not sure about classic application pool, will try anyway.


Avatar of toooki

ASKER

Quite stuck. I created an one line application.
VS2008->File->New->"Web Site" chose Framework ".NET Framework 2.0" from the template dropdown in the create page.
Only created a label in default.aspx file.
Created virtual directory in IIS (in windows XP PC) for the new application location. Default I found it took ASP .NET version 2.0.50727 .
Compiled and published.
I get the same error as in the attached screen in the past post.