Global.ASA does not work in IIS7.5

时光怂恿深爱的人放手 提交于 2019-12-13 03:21:15

问题


I have many projects written in old classic ASP where Global.asa used to work perfectly fine. Since I have installed Windows 7 with IIS7.5, none of my projects are working.

Below is the code for Global.asa

<Script language=vbscript runat = server>

Sub Application_OnStart() 

dim objConn, connectionString

set objConn = Server.CreateObject("ADODB.Connection") 

connectionString = "DSN=otsDSN; UID=admin;PWD=;"

objConn.ConnectionTimeout = 5

The error comes in this line. Have referred many websites, even IIS.Net but still no luck.

objConn.Open connectionString

Application("otsAppConn") = objConn

end Sub

The error thrown by IIS is

error '80004005' /ot/admin/page1.asp, line 33 and the Application object which used to carry the connection object string in older family of IIS now showing, Provider=MSDASQL.1; instead of complete connection string.

All the projects are listed as Application in IIS7.5 which I could see using the appcmd list apps

Appreciate if someone can help on this..


回答1:


see if the information in the provided link helps you get some better debug info. About halfway down there is a setting you can turn on that allowed me to see what was behind the error code when I was trying to run a classic asp in iis 7.5 http://learn.iis.net/page.aspx/564/classic-asp-script-error-messages-no-longer-shown-in-web-browser-by-default/.




回答2:


Managed to resolve the issue after long troubleshooting in IIS.

  1. Converted the DSN connection provider to Microsoft Access Driver (.mdb) instead of Microsoft Access Driver (.mdb, *.accdb)

  2. Created Connection String in IIS under my website under Custom

    "/commit:MACHINENAME /section:connectionStrings /+"[connectionString='Data Source=localhost;Integrated Security=SSPI;Initial Catalog=otmasterdb;',name='otmasterdb',providerName='Provider=Microsoft.Jet.OLEDB.4.0;']" 
    

    and gave the Connection Name same as the DSN connection

  3. Changed the Global.asa connectionString from "DSN=aaa;UID=admin;PWD=;" to "aaa" only by removing the latter portion.
    The new code looks like this:

    Sub Application_OnStart()
            dim objConn, connectionString
            set objConn = Server.CreateObject("ADODB.Connection")
            connectionString = "otsDSN"
    
            objConn.ConnectionTimeout = 5
            objConn.Open connectionString
    
            Application("otsAppConn") = objConn
    end Sub
    


来源:https://stackoverflow.com/questions/7215871/global-asa-does-not-work-in-iis7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!