0

I need to let an unprofessional to be able to install an ASP.NET application by himself.

The installer (a person) will copy the application files into a virtual directory.

The installer will get a SQL server name username and password suitable for creating a database from the sysadmin.

The application has a web page which is automatically creating an empty database on a designated SQL server which its name is given by the installer who is setting the server's name using a specific web-form.

I would like to have the installation page to appear on the master menu only once.

The installation page has a link in the master as an asp:MenuItem .

Which is the best SIMPLE way to suppress this menu item after the database installation?

I thought of a specific variable in Web.config, which will hold the value stating if the database is already installed and ready to be use or not, but some doesn't like this solution.

Luis Perez
  • 27,650
  • 10
  • 79
  • 80
elarrow
  • 687
  • 3
  • 11
  • 19
  • 2
    i think you should have custom user config for such task rather than using web.config. – Amritpal Singh Mar 16 '12 at 20:32
  • To add to Amritpal Singh's suggestion. For your particular use case you might want to use a cookie to store this information if your user does not actually log into the application. Unless you only want your about page to only show once ever. – Biff MaGriff Mar 16 '12 at 20:37
  • You can cache the vars stored in the config file for the duration of the session. Cookies might be best for your situation; you do NOT want to save data to your Web.Config file - that is not what it's intended for :) – IrishChieftain Mar 16 '12 at 20:40
  • Please do not edit your question to remove all content. You can make clarifying edits, but if you want to ask another question, please use the Ask Question button again. Thanks. – Adam Lear Mar 17 '12 at 06:52

1 Answers1

2

This gives you a range of options:

Nine Options for Managing Persistent User State in Your ASP.NET Application

You could use the appSettings section in the Web.Config file to generate variables at project or folder level and cache the vars for the duration of the session:

<appSettings>
    <add key="customsetting1" value="Some text here"/>
</appSettings>

System.Configuration.Configuration rootWebConfig1 =                  
    System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);

if (rootWebConfig1.AppSettings.Settings.Count > 0)
{
    System.Configuration.KeyValueConfigurationElement customSetting = 
        rootWebConfig1.AppSettings.Settings["customsetting1"];
    if (customSetting != null)
        Console.WriteLine("customsetting1 application string = \"{0}\"",   
            customSetting.Value);
    else
        Console.WriteLine("No customsetting1 application string");
}

More info: http://msdn.microsoft.com/en-us/library/ms228154.aspx

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
  • I would read in the file when the app starts, store vars in session, then write them back to the file at the end - maybe from the global.asax file: http://stackoverflow.com/questions/720969/when-to-use-application-start-vs-init-in-global-asax – IrishChieftain Mar 16 '12 at 21:08
  • Why not just database it? You could create a user profile and associate a bool with a particular user. Must be a 100 ways to do this but the best way will be dictated by your particular needs. – IrishChieftain Mar 16 '12 at 21:24
  • What do you mean exactly by "create the database"? – IrishChieftain Mar 16 '12 at 21:40
  • Just doesn't sound right to me... hopefully someone else can chime in and offer some advice. Why even think of creating a database this way? – IrishChieftain Mar 16 '12 at 21:52
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/8981/discussion-between-elarrow-and-irishchieftain) – elarrow Mar 16 '12 at 22:00
  • Surely you are not duplicating either databases or sets of tables on a per user basis? I think you need to update your question explaining the DB design and what you are trying to accomplish overall. Just explain the user scenarios :) – IrishChieftain Mar 16 '12 at 22:01