0

I am using Arvixe as my web host and have created a .NET 4.5 MVC app with individual user accounts. I created an ADO.NET Entity Data Model database first named "SecurityModel", updated my ApplicationDbContext to "joerdie_securityEntities", and switched my connection string to the following:

   <add name="joerdie_securityEntities" connectionString="Data Source=localhost;Initial Catalog=joerdie_security;Integrated Security=false;User ID=myID;Password=myPassword" providerName="System.Data.SqlClient" />

I did this so that I could use my own SQL server db also hosted with Arvixe. When I deploy this base application, I am able to create a new user without an issue, and new users are entered into the SQL server database. However, when I try to create a new user in localhost the user creation fails in the following method during the declaration of "result".

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Register(RegisterViewModel model)
    {
        if (ModelState.IsValid)
        {
            var user = new ApplicationUser { UserName = model.Email, Email = model.Email };

            try
            {
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);

        }

            catch (Exception e) { 
                Console.WriteLine(e.Message);
            }


    }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

An Exception is caught but is null, and I never make it to the following if statement. I am able to bring in other models to this exact SQL Server instance and they update just fine. How do I set this up to be able to debug on my localhost pointing to my SQL Server instance?

Edit: Adding Console output.

Exception thrown: 'System.Data.SqlClient.SqlException' in mscorlib.dll
Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.Request","time":"2018-03-24T02:31:06.2230673Z","tags":{"ai.operation.name":"POST Account/Register","ai.operation.id":"MJK7rNb0X7k=","ai.location.ip":"::1","ai.cloud.roleInstance":"joerdie-Desktop","ai.internal.sdkVersion":"web:2.2.0-738"},"data":{"baseType":"RequestData","baseData":{"ver":2,"id":"MJK7rNb0X7k=","name":"POST Account/Register","duration":"00:01:01.1920000","success":true,"responseCode":"200","url":"http://localhost:53015/Account/Register","properties":{"DeveloperMode":"true"}}}}
The thread 0x10ec has exited with code 0 (0x0).
joerdie
  • 379
  • 1
  • 6
  • 18
  • "An Exception is caught but is null" - this statement surely cannot be true. Change your Console.WriteLine to show `e.ToString()`, which will show what the problem is, and allow us to help you. My bet would be that the user/password combination in the connection string hasn't been set up on your local instance correctly. – Richardissimo Mar 24 '18 at 05:24
  • For example, it doesnt look like you're suffering from [this](https://stackoverflow.com/questions/5634417/caught-exception-is-null-itself). – Richardissimo Mar 24 '18 at 05:57
  • As a precaution, I did change my exception variable name to "eeeeee" and ran it toString() I received the same response noted in my edit. As for the user name and password combo, the deployed and desktop instances share the same details. – joerdie Mar 24 '18 at 14:10
  • The thing is that the information in the question clearly indicates that an SqlException is being thrown. If the exception was null, it would not be possible to determine what the type of the exception was. Also the message posted in the edit to the question has not come from the `Console.WriteLine(e.Message);` nor from using e.ToString(). To find it, [Tell-the-debugger-to-break-when-an-exception-is-thrown](https://learn.microsoft.com/en-gb/visualstudio/debugger/managing-exceptions-with-the-debugger#tell-the-debugger-to-break-when-an-exception-is-thrown). Then give us the exception. – Richardissimo Mar 24 '18 at 21:00

0 Answers0