Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Pages downloading instead of posting????

Status
Not open for further replies.

gnibbles

Programmer
Mar 15, 2000
79
CA
I am trying to setup my ASP Pages, but when I try to post another page instead of going to that page the browser tries to download. Here's some sample code:

This is for the interface page with some text fields and two buttons. The second page is just displaying data from a database.

<form method=&quot;GET&quot; action=&quot;searchresults.asp&quot;>
<div align=&quot;center&quot;><center><p>Job Number: <input type=&quot;text&quot; name=&quot;txtJobNum&quot; size=&quot;17&quot;></p>
</center></div><div align=&quot;center&quot;><center><p>Invoiced By : <input type=&quot;text&quot; name=&quot;txtInvoiced&quot; size=&quot;17&quot;></p>
</center></div><div align=&quot;center&quot;><center><p>Client Name: <input type=&quot;text&quot; name=&quot;txtClient&quot; size=&quot;17&quot;></p>
</center></div><div align=&quot;center&quot;><center><p>Description : <input type=&quot;text&quot; name=&quot;txtDesc&quot; size=&quot;17&quot;></p>
</center></div><div align=&quot;center&quot;><center><p>Date : <input type=&quot;text&quot; name=&quot;txtDate&quot; size=&quot;17&quot;></p>
</center></div><div align=&quot;center&quot;><center><p>

<input type=&quot;submit&quot; value=&quot;Search&quot; name=&quot;cmdSearch&quot;>
<input type=&quot;reset&quot; value=&quot;Clear Form&quot; name=&quot;cmdReset&quot;></p>
</center></div>


gnibbles
nturpin@excite.com
 
OK, just to clean up a little here so I can see it a little better.
Code:
<form method=&quot;
post
Code:
&quot; action=&quot;searchresults.asp&quot;>

  <div align=&quot;center&quot;><center><p>Job Number: <input type=&quot;text&quot; name=&quot;txtJobNum&quot; size=&quot;17&quot;></p>
  </center></div>

  <div align=&quot;center&quot;><center><p>Invoiced By : <input type=&quot;text&quot; name=&quot;txtInvoiced&quot; size=&quot;17&quot;></p>
  </center></div>

  <div align=&quot;center&quot;><center><p>Client Name: <input type=&quot;text&quot; name=&quot;txtClient&quot; size=&quot;17&quot;></p>
  </center></div>

  <div align=&quot;center&quot;><center><p>Description : <input type=&quot;text&quot; name=&quot;txtDesc&quot; size=&quot;17&quot;></p>
  </center></div>

  <div align=&quot;center&quot;><center><p>Date : <input type=&quot;text&quot; name=&quot;txtDate&quot; size=&quot;17&quot;></p>
  </center></div>

  <div align=&quot;center&quot;><center><p>
   <input type=&quot;submit&quot; value=&quot;Search&quot; name=&quot;cmdSearch&quot;>
   <input type=&quot;reset&quot; value=&quot;Clear Form&quot; name=&quot;cmdReset&quot;></p></center></div>

</form>


OK, I've only made two changes here (marked in RED). You need a closing form tag at the end so if you were missing that, it could have been your problem. Unless you absolutely need to see the key/value pairs in the URL string, change the method to post. That way, a user won't be able to malform a URL, either intentionally or accidentally, and cause any problems. I've changed it in the content above. All you have to do in searchresults.asp is change your Request.QueryString methods to Request.Form and everything will behave identically.

ToddWW
 
yeah the </form> is there already I just didnt get it copied over. But I changed the <form method=&quot;post&quot; action=&quot;searchresults.asp&quot;> but I still get the same results.


gnibbles
nturpin@excite.com
 
I'm not quite sure I understand your situation. Can you let me know what you are referring to when you say the browser starts to download ??

ToddWW
 
can you post some of the code from searchresults.asp? sounds like there might be something in that processing that is your problem.
 
Its similar to if you were trying to download a file from the net but it happens when i try to load an asp page. It happens everytime I try even if its 2 or 3 different pages.


here's the code from searchresults.asp

<%
Option Explicit

Dim dcnDB
Dim rsJob
DimstrSQL
Dim blnAddedWhere

setdcnDB = Server.CreateObject(&quot;ADODB.Connection&quot;)
dcnDB.ConnectionString = &quot;c:\Database_Files\FJG_JobFiles.udl&quot;
dcnDB.Open

strSQL = &quot;SELECT * FROM Jobs &quot;
clnAddedWhere = False

If Request (&quot;txtJobNum&quot;)<> &quot;&quot; Then
If Not blnAddedWhere Then
strSQl= strSQL & &quot; Where &quot;
blnAddedWhere = True
End If
strSQL = strSQL & &quot; Job_Number LIKE '%&quot; _
& Request(&quot;txtJobNum&quot;) _
&&quot;%' &quot;
End If

If Request (&quot;txtInvoiced&quot;)<> &quot;&quot; Then
If Not blnAddedWhere Then
strSQl= strSQL & &quot; Where &quot;
blnAddedWhere = True
End If
strSQL = strSQL & &quot; Invoiced_By LIKE '%&quot; _
& Request(&quot;txtInvoiced&quot;) _
&&quot;%' &quot;
End If

If Request (&quot;txtClient&quot;)<> &quot;&quot; Then
If Not blnAddedWhere Then
strSQl= strSQL & &quot; Where &quot;
blnAddedWhere = True
End If
strSQL = strSQL & &quot; Client LIKE '%&quot; _
& Request(&quot;txtClient&quot;) _
&&quot;%' &quot;
End If

If Request (&quot;txtDesc&quot;)<> &quot;&quot; Then
If Not blnAddedWhere Then
strSQl= strSQL & &quot; Where &quot;
blnAddedWhere = True
End If
strSQL = strSQL & &quot; Description LIKE '%&quot; _
& Request(&quot;txtDesc&quot;) _
&&quot;%' &quot;
End If

If Request (&quot;txtDate&quot;)<> &quot;&quot; Then
If Not blnAddedWhere Then
strSQl= strSQL & &quot; Where &quot;
blnAddedWhere = True
End If
strSQL = strSQL & &quot; Date LIKE '%&quot; _
& Request(&quot;txtDAte&quot;) _
&&quot;%' &quot;
End If

strSQl = strSQl & &quot; ORDER By Job_Number&quot;
set rsJob = dcnDBExecute(strSQl)


%>
<html>

<head>
<title>Search Results</title>
</head>

<body>

<h1>Search Results </h1>

<ul>
<%

Do While Not rsJob.EOF
Response.Write &quot;<LI>&quot; _
& rsJob (&quot;Job_Number&quot;) _
& rsJob (&quot;Invoiced_By&quot;)_
& rsJob (&quot;Client&quot;)_
& rsJob (&quot;Description&quot;)_
& rsJob (&quot;Date&quot;)
rsJob.MoveNext
Loop
%>
</ul>
<a href=&quot;SearchJobs.asp&quot;>

<p>Back to Search Form </a></p>
</body>
</html>
<%
rsJob.Close
dcnDB.Close
%>


gnibbles
nturpin@excite.com
 
You've got a bad Connection string. You need to specify the database driver for that database. I think the browser is trying to download the database or something like that. Here's an example of an MS Access connection string.
Code:
dcnDB.ConnectionString = &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=E:\appfiles\dbfdir\cougar.mdb&quot;
ToddWW
 
Or alternatively, and it may be easier, you can setup a DSN (Data Source Name) in your server, then all you have to do is specify that name.
Code:
dcnDB.ConnectionString = &quot;DSN=mydsn&quot;
This might be helpful faq333-178

ToddWW
 
I changed it, but still no go.

gnibbles
nturpin@excite.com
 
Can these pages be tested without Personal Web Server or any kind of web server.

gnibbles
nturpin@excite.com
 
Yes, you can upload the pages to any Windows NT or Windows 2000 server running IIS. Any ISP can handle this request. Microsoft Windows 2000 Professional which is designed to load onto a desktop comes with IIS and it is very stable.

Did you try setting up a DSN ??

ToddWW
 
Yes I tried the setting up the DSN, the strange thing is last year or the year before I had all this stuff down path and working and now I'm picking it up again and it doesnt work. I don't think its the database connectivity thats causing it because im running NT on my Computer here at work. As well I was trying to do a simple login page and once it went to the engine.asp it was asking me to download that page as well. This is very frustrating.

gnibbles
nturpin@excite.com
 
My thinking is that there is a problem in the server setup if it's asking you to download the .asp file. I'm not really familiar with that part of the game. But I do know that if the asp pages are not on an IIS or PWS server, the browser will try to download them as a file.

I'm thinking now that this is your problem.

ToddWW
 
Thanks for your help though.

gnibbles
nturpin@excite.com
 
If the ASP resided in a directory that was not marked for Execute Scripts, it would try to download it but it appears that the second ASP is in the same directory as the first page. Is the first page an HTML only page? If yes, then it is possible to get the first page (HTML) to display but the ASP to download because it can not execute it as script. Compare Code (Text)
Generate Sort in VB or VBScript
 
no they are all asp pages, i think its a server problem like Todd because I had some troubles installing and NT is something else to work with so...

gnibbles
nturpin@excite.com
 
JohnYingling and ToddWW are correct. The permissions need to be set to execute and allow files of type .asp. If not, it will give this message. The directory CHMOD needs to be set to at least 755.
 
I am having the same problem. I went into the web sharing under folder properties and gave the alias full permissions. My default web site under Internet Information Services is up and running. ASP files still want to download instead of open though. Running win2k.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top