publish asp.net web application

B

berkeleydb_user

Guys

I developed a small asp web service app in Visual Studio .NET. To
deploy on another server, I just copied the whole dir as is from my
c:\inetpub\wwwroot to the same dir on destination server, but I get
this error. I'm using excel automation etc:

Compiler Error Message: CS0246: The type or namespace name 'Excel'
could not be found (are you missing a using directive or an assembly
reference?)

Source Error:

Line 110: GC.Collect();
Line 111: /* src excel */
Line 112: Excel.Application srcExcel = new Excel.ApplicationClass();
Line 113: Excel._Workbook srcWb = srcExcel.Workbooks.Open(fName,
Missing.Value, Missing.Value,
Line 114: Missing.Value, Missing.Value, Missing.Value,

Can you tell me what I'm doing wrong? Please help.,

thanks
 
M

Mark Rae

Can you tell me what I'm doing wrong? Please help.,

Presumably, Microsoft Office (or, at least, Excel) is installed on your
development box and not your web server...?
 
B

berkeleydb_user

Excel is there for sure. I'm trying this on Windows Server 2003.

Actually it was my mistake. I edited the file so I could put without
"codebehind" etc. Now I really copied the whole dir from development to
server but when I click on my submit button, nothing happens, page just
comes back and I see 'Done' at the bottom of browser. whats going on?

thanks
 
M

Mark Rae

Excel is there for sure. I'm trying this on Windows Server 2003.

Excel is not part of Windows Server 2003 - are you absolutely certain you
installed it on your server...?
Actually it was my mistake. I edited the file so I could put without
"codebehind" etc. Now I really copied the whole dir from development to
server but when I click on my submit button, nothing happens, page just
comes back and I see 'Done' at the bottom of browser. whats going on?

Impossible to say without more information...
 
B

berkeleydb_user

Thanks for your help Mark. Here is my actual code. Its pretty simple. I
have a field where user uploads an excel file. I have to process that
excel file and save it. The webpage doesn't seem to be doing anything.
I enabled running 'active server pages' on IIS admin. Whole office is
installed on this server.

thanks

Webform1.aspx
=================
<%@ Page aspcompat=true language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form action="WebForm1.aspx" method="post"
encType="multipart/form-data" runat="server">
<P><asp:label id="uploadLabel" style="Z-INDEX: 101; LEFT: 33px;
POSITION: absolute; TOP: 53px" runat="server" Width="135px"
Font-Bold="True" Font-Names="Arial" Font-Size="Smaller">Upload your bid
file:</asp:label><INPUT id="File1" style="Z-INDEX: 102; LEFT: 185px;
WIDTH: 432px; POSITION: absolute; TOP: 50px; HEIGHT: 22px" type="file"
size="52" name="uploadControl" runat="server">
<asp:button id="uploadButton" style="Z-INDEX: 103; LEFT: 343px;
POSITION: absolute; TOP: 134px" runat="server" Font-Bold="True"
Font-Names="Arial" Text="Upload"></asp:button>
<asp:label id="resultNum" style="Z-INDEX: 104; LEFT: 31px; POSITION:
absolute; TOP: 202px" runat="server" Width="548px" Font-Bold="True"
Font-Names="Arial" Font-Size="X-Small" BackColor="#FFFFC0"
Visible="False">Label</asp:label><asp:table id="tblResults"
style="Z-INDEX: 105; LEFT: 33px; POSITION: absolute; TOP: 231px"
runat="server" Width="332px" Font-Bold="True" Font-Names="Arial"
Font-Size="X-Small" BackColor="InactiveCaptionText" Visible="False"
CellPadding="0" CellSpacing="0" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" Height="24px"></asp:table><asp:label id="lblVendor"
style="Z-INDEX: 106; LEFT: 31px; POSITION: absolute; TOP: 174px"
runat="server" Width="275px" Font-Bold="True" Font-Names="Arial"
Font-Size="Smaller" BackColor="#FFFFC0"
Visible="False">Label</asp:label><asp:image id="imgChart"
style="Z-INDEX: 107; LEFT: 401px; POSITION: absolute; TOP: 237px"
runat="server" Width="552px" Visible="False"
Height="432px"></asp:image><asp:label id="lblPasswd" style="Z-INDEX:
108; LEFT: 34px; POSITION: absolute; TOP: 99px" runat="server"
Width="84px" Font-Bold="True" Font-Names="Arial"
Font-Size="Smaller">Password:</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 109; LEFT: 186px; POSITION: absolute; TOP: 91px"
runat="server" MaxLength="10"
TextMode="Password"></asp:textbox><asp:requiredfieldvalidator
id="RequiredFieldValidator1" style="Z-INDEX: 110; LEFT: 357px;
POSITION: absolute; TOP: 94px" runat="server"
ControlToValidate="txtPassword" ErrorMessage="Password cannot be
empty"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="RequiredFieldValidator2" style="Z-INDEX: 111; LEFT: 635px;
POSITION: absolute; TOP: 52px" runat="server" ControlToValidate="File1"
ErrorMessage="Please specify your excel bid
file"></asp:requiredfieldvalidator></P>
</form>
</body>
</HTML>


here is my webform1.aspx.cs file
=========================

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection;
using System.Runtime.InteropServices;

/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label uploadLabel;
protected System.Web.UI.HtmlControls.HtmlInputFile File1;
protected System.Web.UI.WebControls.Label resultNum;
protected System.Web.UI.WebControls.Table tblResults;
protected System.Web.UI.WebControls.Label lblVendor;
protected System.Web.UI.WebControls.Image imgChart;
protected System.Web.UI.WebControls.Label lblPasswd;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator2;
protected System.Web.UI.WebControls.Button uploadButton;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
resultNum.visible = true;
resultNum.text = "visible";
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.uploadButton.Click += new
System.EventHandler(this.uploadButton_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
private void uploadButton_Click(object sender, System.EventArgs e)
{
if ( File1 != null )
{
resultNum.text = "file field is not
blank";
}
}
}
 
B

berkeleydb_user

Hi Mark

I made up this small app from a working app. This one does same thing.
It just returns the same page back without doing anything. I select a
file from my c: on server, and click upload. I expect 'resultNum' field
to be visible and show some text. it doesn't. the page just comes back
as it is :((

here is the code:
=============

<% @Page Language="C#" %>
<html>
<head>
<title>File upload in ASP.NET</title>
</head>
<body bgcolor="#ffffff" style="font:8pt verdana;">
<script language="C#" runat="server">

void uploadButton_Click(object sender, System.EventArgs e)
{
resultNum.Visible = true;
if ( File1 != null ) {
resultNum.Text = "abcd";
}
else {
resultNum.Text = "efgh";
}
}
</script>


<form action="apacx.aspx" method="post" enctype="multipart/form-data"
runat="server">
<P><asp:label id="uploadLabel" style="Z-INDEX: 101; LEFT: 33px;
POSITION: absolute; TOP: 53px" runat="server" Width="135px"
Font-Bold="True" Font-Names="Arial" Font-Size="Smaller">Upload your bid
file:</asp:label><INPUT id="File1" style="Z-INDEX: 102; LEFT: 185px;
WIDTH: 432px; POSITION: absolute; TOP: 50px; HEIGHT: 22px" type="file"
size="52" name="uploadControl" runat="server">
<asp:button id="uploadButton" style="Z-INDEX: 103; LEFT: 343px;
POSITION: absolute; TOP: 134px" runat="server" Font-Bold="True"
Font-Names="Arial" Text="Upload"></asp:button>
<asp:label id="resultNum" style="Z-INDEX: 104; LEFT: 31px; POSITION:
absolute; TOP: 202px" runat="server" Width="548px" Font-Bold="True"
Font-Names="Arial" Font-Size="X-Small" BackColor="#FFFFC0"
Visible="False">Label</asp:label><asp:table id="tblResults"
style="Z-INDEX: 105; LEFT: 33px; POSITION: absolute; TOP: 231px"
runat="server" Width="332px" Font-Bold="True" Font-Names="Arial"
Font-Size="X-Small" BackColor="InactiveCaptionText" Visible="False"
CellPadding="0" CellSpacing="0" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" Height="24px"></asp:table><asp:label id="lblVendor"
style="Z-INDEX: 106; LEFT: 31px; POSITION: absolute; TOP: 174px"
runat="server" Width="275px" Font-Bold="True" Font-Names="Arial"
Font-Size="Smaller" BackColor="#FFFFC0"
Visible="False">Label</asp:label><asp:image id="imgChart"
style="Z-INDEX: 107; LEFT: 401px; POSITION: absolute; TOP: 237px"
runat="server" Width="552px" Visible="False"
Height="432px"></asp:image><asp:label id="lblPasswd" style="Z-INDEX:
108; LEFT: 34px; POSITION: absolute; TOP: 99px" runat="server"
Width="84px" Font-Bold="True" Font-Names="Arial"
Font-Size="Smaller">Password:</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 109; LEFT: 186px; POSITION: absolute; TOP: 91px"
runat="server" MaxLength="10"
TextMode="Password"></asp:textbox><asp:requiredfieldvalidator
id="RequiredFieldValidator1" style="Z-INDEX: 110; LEFT: 357px;
POSITION: absolute; TOP: 94px" runat="server"
ControlToValidate="txtPassword" ErrorMessage="Password cannot be
empty"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="RequiredFieldValidator2" style="Z-INDEX: 111; LEFT: 635px;
POSITION: absolute; TOP: 52px" runat="server" ControlToValidate="File1"
ErrorMessage="Please specify your excel bid
file"></asp:requiredfieldvalidator></P>
</form>

<span id=txtOutput style="font: 8pt verdana;" runat="server" />

</body>
</html>



here is working code for uploading a file. this one works on same
server.
==============================
<% @Page Language="C#" %>
<html>
<head>
<title>File upload in ASP.NET</title>
</head>
<body bgcolor="#ffffff" style="font:8pt verdana;">
<script language="C#" runat="server">
void btnUploadTheFile_Click(object Source, EventArgs evArgs)
{
string strFileNameOnServer = txtServername.Value;
string strBaseLocation = "d:\\downloads\\temp\\";

if ("" == strFileNameOnServer)
{
txtOutput.InnerHtml = "Error - a file name must be specified.";
return;
}

if (null != uplTheFile.PostedFile)
{
try
{
uplTheFile.PostedFile.SaveAs(strBaseLocation+strFileNameOnServer);
txtOutput.InnerHtml = "File <b>" +
strBaseLocation+strFileNameOnServer+"</b> uploaded successfully";
}
catch (Exception e)
{
txtOutput.InnerHtml = "Error saving <b>" +
strBaseLocation+strFileNameOnServer+"</b><br>"+ e.ToString();
}
}
}
</script>


<form enctype="multipart/form-data" runat="server">
<table>
<tr>
<td>Upload Excel file:</td>
<td><input id="uplTheFile" type=file runat="server"></td>
</tr>
<tr>
<td>Name on server:</td>
<td><input id="txtServername" type="text" runat="server"></td>
</tr>
<tr>
<td colspan="2">
<input type=button id="btnUploadTheFile" value="Upload"
OnServerClick="btnUploadTheFile_Click"
runat="server">
</td>
</tr>
</table>
</form>

<span id=txtOutput style="font: 8pt verdana;" runat="server" />

</body>
</html>
 
B

berkeleydb_user

Hi

This is my first asp.net web application. Not sure what is going on.
Here is what I found. When I use <asp:.....> tag its NOTworking. First
listing works but the second doesnt!!!! must be some basic
mistake....pl help me out.

working source.....no <asp:....> tags. when i click on Upload button I
see the text box getting filled with "asdfasdfa"
======================
<% @Page Language="C#" %>
<html>
<head>
<title>File upload in ASP.NET</title>
</head>
<body bgcolor="#ffffff" style="font:8pt verdana;">
<script language="C#" runat="server">

void uploadButton_Click(object sender, System.EventArgs e)
{
txtbox.Value = "asdfasdfa";
}
</script>


<form action="apacx.aspx" method="post" enctype="multipart/form-data"
runat="server">
<input type="text" runat="server" id="txtbox"><p>
<INPUT id="File1" type="file" name="uploadControl"
runat="server">
<INPUT id="uploadButton" type="button"
OnServerClick="uploadButton_Click" runat="server" Value="Upload">

</form>

<span id=txtOutput style="font: 8pt verdana;" runat="server" />

</body>
</html>


this doesn't work....page just returns.
==================
<% @Page Language="C#" %>
<html>
<head>
<title>File upload in ASP.NET</title>
</head>
<body bgcolor="#ffffff" style="font:8pt verdana;">
<script language="C#" runat="server">

void uploadButton_Click(object sender, System.EventArgs e)
{
txtbox.Value = "asdfasdfa";
}
</script>


<form action="apacx.aspx" method="post" enctype="multipart/form-data"
runat="server">
<input type="text" runat="server" id="txtbox"><p>
<INPUT id="File1" type="file" name="uploadControl"
runat="server">
<asp:button id="uploadButton" type="button"
OnServerClick="uploadButton_Click" runat="server"
Text="Upload"></asp:button>

</form>

<span id=txtOutput style="font: 8pt verdana;" runat="server" />

</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top