locked
Modify class file in web setup? RRS feed

  • Question

  • User-691412093 posted

    Hi, I'm a newbie in ASP.NET and right now my web application is almost finished.

    I have a little issue, I need to modify a connection string in a class in my app_code folder when the setup is running.

    I know that I need a Custom Action for this, but I have no idea in how the code must be.

    Does anyone can give me a reference on this?

    Thank you

    Jubu


    Thursday, May 27, 2010 1:43 PM

Answers

All replies

  • User-1790381586 posted


    Could you please elaborate your problem a little?
    I think you are trying to set a specific connection string based on the environment, is that the case?
    The best place to keep connection string would be the web config. Please refer to this article - http://msdn.microsoft.com/en-us/library/ms178411.aspx
    Also, for the deployment purpose you should maintain different web configs for different environments.
    In case you are using .NET 4.0 / Visual Studio 2010, the studio can do some pretty cool stuff to help you.

     

    Could you please elaborate your problem a little?

    I think you are trying to set a specific connection string based on the environment, is that the case?


    The best place to keep connection string would be the web config. Please refer to this article -

    http://forums.asp.net/p/1562852/3877874.aspx

    Also, for deployment purpose, you should maintain different web configs for different environments.

    In case you are using .NET 4.0 / Visual Studio 2010, the studio can do some pretty cool stuff for you in this regard.

     


    Thursday, May 27, 2010 4:31 PM
  • User-691412093 posted

    Thank you for your reply MayankSri,

    Yes, I have in this class a connection string as a string variable.

    I already have a custom action in my web setup to edit my connection strings in my web.config, I just want to edit the connection string in this specific class just like it does in web.config.

    Thanks!

    Thursday, May 27, 2010 6:27 PM
  • User-1370807927 posted

    This is long standing for the "web setup".  This is where the new msdeploy that VS10 leverage have much more flexibility by its deploy time parameter.

    In VS10, we support the msdeploy which allow the deploy time parameters.

    http://technet.microsoft.com/en-us/library/dd722763(WS.10).aspx#BKMKPackagesAndParameters 

    It just so happen VS leverage the Parameter to perform on the xml file (web.config.)

    You can do the same thing with a class file, with the "TextFile" as scope, which by default use the "Regex" for the match.

    http://technet.microsoft.com/en-us/library/dd569084(WS.10).aspx#BKMK_ParameterKindSettings

    Now, all you need to do is extending Web Publish Pipeline to also handle your special class....

    http://msdn.microsoft.com/en-us/library/dd394698.aspx 

    HTH.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 28, 2010 2:54 PM