How to use aspnetdb.mdf on my production server

Posted on 2014-09-01
Last Modified: 2015-09-01
I would like to protect some pages in my web site.

I tried with a very simple project with one default page, a login.aspx page and a protected folder( with one page).
Vs (express) created a aspnetdb.mdf file.

On my local environnement it works fine but when i try to move to my hosting solution (arvixe) , nothing is working anymore.
I guess the problem is when the login form try to read informations in the aspnetdb.mdf.
i add a connection string in my web.config but i am not sure it's the right way...

Someone could help me to solve the problem ?
Question by:Ok123
    LVL 25

    Expert Comment

    by:Dan McFadden
    A little more clarification is needed.  I assume you are using SQL Express and IIS?  Or are you using an Access database?

    You can not just copy a *.mdf from 1 server to another.  For a direct copy, you first must detach the database from SQL Server (using SQL Server Management Studio), transfer the *.mdf file to the new server (which needs to have some form of SQL Server running), then attach the database and verify that the db is online.

    Then, if your IIS is configured and running correctly, you should be in business.


    Author Comment

    Hi ,
    I am working with VS Studio 2012.
    I am not working with access.
    The aspnetdb.mdf is generated by vs when you add a login control in a login page.

    The problem is to connect that db when i work on my production server.

    LVL 25

    Expert Comment

    by:Dan McFadden
    Then the question is, do you have an instance of SQL Server or SQL Express installed and running on the Prod server?

    VSExpress installs SQL Express during its installation process, which is why you can use a SQL database on your local device.

    1. download SQL Server Express with management tools (SSMS)
    2. install it on your prod server
    3. attach your database as noted above.

    I would recommend first trying this on a replica of your production server.  I would verify all the software that is installed/running on your prod server before dropping a SQL engine on it.


    Author Comment

    yes i have a sql server on the prod server.
    It's an Arvixe shared hosting.
    LVL 25

    Expert Comment

    by:Dan McFadden
    So then, I would follow the steps mentioned above.  Do you have console access to the server?

    Here is a link describing the concept of detaching/attaching a database file.:
    And here is a link to connection strings for apps:

    BTW:  "Arvixe shared hosting" doesn't mean anything.  It gives no context as to what you have on your production server.

    LVL 25

    Accepted Solution

    Any update?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now