Membership/Role Problem When Deploying Site

Discussion in 'ASP.NET / ASP.NET Core' started by rlcraven, Apr 13, 2013.

  1. Hello,

    My new MVC4 site runs as expected on my development machine but when I deploy it I cannot log in as a site user -- the error is "The Role Manager feature has not been enabled." This is after uploading my SQL Server database to the web server.

    Locally I have been using Integrated Security with SQL Server and with DiscountASP I am using the DASP supplied connection string using SQL Authentication.

    I tried changing the connection string in my web.config to use SQL Authentication locally (having first set up a SQL Server login) and that brings up this error: "The ASP.NET Simple Membership database could not be initialized.".

    Scratching my head... does anyone have ideas about how to tackle this?

    Thanks!

    Randy
     
  2. Update: I can log in locally using SQL Authentication, all that was required was to reconfigure SQL Server for mixed mode authentication. However, I am still getting the same error message when I try to login to the live site.
     
  3. Update: the problem went away after adding the following line to web.config in the <appSettings> section:

    <add key="enableSimpleMembership" value="true" />
     
  4. I'm not sure why the application worked locally without that line in web.config but didn't work in deployment.
     
  5. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

  6. Hello RayH,
    I checked out the link you provided here, but no luck. I guess Ricraven is using the MVC4 from developed with VS2010, so, I was wondering if you have a link to the new MVC4 yet still running .NET 4 developed with VS2012-13?
     
  7. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    There shouldn't be a difference. I'm running Visual Studio 2012 here in the office and recently created a web login form without any problems.
     
    basbak likes this.
  8. Hi basbak,

    I'm using VS2012 also.

    For me, membership is always tricky to get set up. If you can share more information about your problem we will try to help. I usually find the best answers on stackoverflow.com -- just enter the text of your error message. Or just google the error text.
     
    basbak and andcon like this.
  9. Yeah, membership is always a problem and I appreciate your help. I have solved the small problems but now!
    Strangest thing with the SQL server is that I can connect to it and do all SQL transactions from my dev machine, yet it my site's Login/register can not find it. The site is basbaktechs.com (try it)
    Do you have any KD### (knowledge base article) regarding this new error
    provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
     
  10. LOL, now it is not doing anything at all, not even a single error to let me know what's happening, anyway I'm gonna try a different yet more drastic approach this time and we shall see if that will get a response.
    Thanx again.
    But do you think that the cross platform Authentication is messing with it?
     
  11. Pardon me if I'm asking too simple a question... you know that the connection string is different for DASP that for your dev machine, right? That caused me a problem until I figured that out. when you publish, on the connection tab you need to enter the info for your DASP database. To get that, go to MS SQL Manager, select your db, click manage, and the connection string is listed there. Hopefully that will help. If not let us know.
     
    basbak likes this.
  12. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Have you tried recompiling your application and then re-uploading? Can you also double check your code is referencing the connection string in your web.config file? I usually see the error: 26 when an application tries to reference a SQL Server Express instance.
     
    basbak likes this.
  13. No pun or insult inteded there friend. The web.config is suited for the site and it is different than that of my dev machine. The app runs perfectly on my machine.
    But I will check the file again.
     
  14. Ok I have made a few changes and gave the web.config file a major overhaul, at least now it is giving me a different error
    connection name 'LocalSqlServer' was not found

    So. any ideas guys?
     
  15. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    basbak likes this.
  16. It doesn't work, thanx for the help, I am giving up for today. I'll try again tomorrow.
    Respect.

    BTW, here is my connection string
    <connectionStrings>
    <add name="SQL2008R2_786972_basbak" connectionString="Data Source=tcp:sql2k805.discountasp.net;Initial Catalog=SQL2008R2_786972_basbak;User ID=SQL2008R2_786972_basbak_user;Password=(intentionaly deleted for security);" providerName="System.Data.SqlClient"/>
    </connectionStrings>
     
  17. Hi all

    I'm having a similar problem that you have been having here. My web.config has the correct connection string copied from the database manager page. Correct password inserted. I have added <add key="enableSimpleMembership" value="true" /> to my web.config. but I still get the
    A network-related or instance-specific error occurred.....
    (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified). error at the following line:

    WebSecurity.InitializeDatabaseConnection("WineRaterDB", "Member", "MemberId", "MemberName", autoCreateTables: true);

    However I did put the following code into a controller to test the connection string:

    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WineRaterDB"].ConnectionString;
    SqlConnection con = new SqlConnection(connectionString);
    con.Open();
    SqlCommand command = new SqlCommand("SELECT TOP 2 * FROM member", con);
    SqlDataReader reader = command.ExecuteReader();
    con.Close();

    This code works fine and doesn't throw any error.

    Was there any solution to this problem?

    I'm using MVC4, Visual studio 2012 express, MS Sql 2012

    Cheers Bruce.
     
  18. An update to this. I have now run my application on my local machine and used the discountasp supplied connection string and been able to use simplemembership in my application. It seems to be a problem just running the application on the discount asp servers and connecting to the discountasp database. I have opened a ticked with support about this problem.
     
  19. I see you're using a table other than UserProfile to store the membership information. Perhaps there is additional configuration required somewhere when you do that. That would be one thing I'd look at.

    This sample code that works, is that working in deployment or just on your development machine?

    Good luck,
    Randy
     
  20. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Are you using an SQL CE database? If so, then you also need to include the relevant assemblies in your /bin folder.
     

Share This Page