Changing Global.asax variables from IIS
Can I change acce开发者_C百科ss or edit the values specified in Global.asax from IIS?? The reason is that I don't have the source code and the only change we need right now is to change the connection strings (database) specified in Global.asax.vb file.
Thanks!!
Usually, connection strings are specified in the Web.config for this very reason. If the values are hardcoded, there's no way for you to modify them unless you can change the code. You can setup an identical database (name, creds) and change some config settings so that your database server resolves to the same machine name. That's all I can think of...
Well, I was able to circumvent the issue. Not very elegant and might add to performance load, but was the simplest considering the work involved to recreate the project.
I created another aspx page and set the connection variables using the Application object in the Page's Page_Load, and then did a response.redirect to the previous default file. I was lucky as all code referred to the Application Object, and this was set only in Global.asax - had there been any code which directly specified the connection string - then I would be screwed!
The only overhead was that the Application_Start would be called only once - but overwriting those values with Page_Load will be called every time a request is made. Kind of trade-off I am ready to do.
I could not agree the previous answer as it mentioned the "Ideal" Case and the best practices - it did not solve my problem. The previous solution should be adopted if the previous sql server can be completely demoted.
Thanks Guys!
精彩评论