在传统的ASP读取web.config中值 [英] Reading web.config values in Classic ASP

查看:218
本文介绍了在传统的ASP读取web.config中值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承的遗产传统的ASP网站,我需要支持,而我在建立一个开发/调试环境的过程,所以我不必在生产服务器上运行。

I have inherited a legacy classic asp site that I need to support, and am in the process of setting up a dev/debugging environment so I don't have to work on the production server.

在code是一个有点乱,并有数百literaly连接字符串中围绕各种.asp文件的地方点缀。这些都包含对SQL服务器等硬件codeD引用。

The code is a bit of a mess, and there are literaly hundreds of connection strings dotted around the place in various .asp files. These all contain hard-coded references to the SQL server, etc.

我真的不希望有我的本地开发环境中的SQL数据库的设置,以取代所有这些,所以我在想,如果有一个简单的方法来获得传统的ASP从.NET的web.config文件中读取。这样一来,我可以改变所有的硬件​​codeD连接字符串从这一个地方阅读,然后我只需要在一个地方定义服务器的详细信息。

I really don't want to have to replace all of these with my local dev environment SQL DB settings, so I was wondering if there was an easy way to get classic asp to read from a .net web.config file. This way I could change all of the hard-coded connection strings to read from this one place, and then I only need to define the server details in one place.

这将意味着,我可以接着写code&放;调试本地,所有我必须做的是改变一对夫妇值在部署之前web.config中。

This would mean that I could then write code & debug locally, and all I would have to do is change a couple of values in the web.config before deployment.

请提供你的答案明显的例子,因为我是新来的传统的ASP和放大器;我真的不是在这个阶段喜欢它。不能等待重建这一切在.NET;)

Please provide clear examples in your answer, as I'm new to classic asp & I'm really not liking it at this stage. Can't wait to redevelop it all in .net ;)

感谢

推荐答案

只需使用一个服务器端包含你需要的所有应用程序设置。这将是更容易,速度更快实现比读一个web.config,并给你同样的灵活性。

Just use a server-side-include with all the app settings you need. It will be much easier (and faster) to implement than reading a web.config and give you the same flexibility.

config.asp里

<%
Dim connectionString
connectionString = "your connectionstring here"
%>

的Default.asp

<% Option Explicit %>
<!-- #include virtual="config.asp" -->
<%
'---
' ... use connectionString here
'---
%>

从你告诉你可以提高在其他地方使用SSI太贵遗产的其余部分。

From what you tell you could improve the rest of your heritage using SSI in other places too.

这篇关于在传统的ASP读取web.config中值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆