November Happy Hour will be moved to Thursday December 5th.

EPiServer Webforms to MVC Database Connection Issues

Vote:
 

Hello,

We are in the process of upgrading our site both code wise (Webforms to MVC) and EPiServer version (10 to 11).  We started based off of the Quicksilver B2B site and have been building based off of that, incorporating our code as we go.

One of the issues that we have had is moving our database over to be usable with the new MVC version of the site.  We keep on getting a 404 error for /Login (shown below) as it tries to go the Commerce Migrate page.  The database that we are using is upgraded to the same version as the B2B database is as we had a somewhat working version of the Webforms site upgraded to the same version of EPiServer CMS and Commerce.

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Login

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0

The Login view and all the code has not been changed and is present as it is used to login when using the B2B database.

I tried to solve the issue by changing the web.config for the CMS site to have the AutoMigrateEPiServer set to true in hopes that it would resolve whatever the issues is, but it still goes to the 404 page for the Login trying to get to the Commerce Migrate page.

I was wondering if this is just something that had to do with our database and content for the new site not being one to one as we do not have all the blocks and page types built yet or if this has something else to do with moving from Webforms to MVC?

Thank you,

Kevin Larsen

#194946
Jul 09, 2018 18:52
Vote:
 

This is not a problem with database, but with configuration/routing instead. Migrate page is an Admin page and it requires users to be logged in, so the system will redirect you to the login page. So make sure you have the log in controller/route properly configured.

#194950
Jul 10, 2018 5:43
Vote:
 

Hi Quan,

So I did a quick check with the code hooked up to the B2B database and went to /Login?ReturnUrl=%2Fepiserver%2FCommerce%2FMigrate, which would bring me to the migration page after logging in, and it does redirect me to the login page and once logged in with an admin account I get successfully redirected back to the migration page.  If it was an issue with the controller/route configuration would this still work with the B2B database but not our database?

Thank you,

Kevin Larsen

#194985
Jul 10, 2018 16:12
Vote:
 

It should. I think if you have same settings and just switch the database there should be no problem

#194991
Jul 10, 2018 20:40
Vote:
 

The problem is when I just change out the connection strings to point to our databases in the same code, it gives that same 404 error for the Login page, which since it's running on the same code base shouldn't be an issue as the B2B database works fine.

Thanks!

Kevin Larsen 

#194995
Jul 10, 2018 23:30
Vote:
 

Does your new ("problematic") database contains a Login page type defined ? 

#195001
Jul 11, 2018 8:09
Vote:
 

We did have a different login page (custom block and separate page template) set up in database. I went and deleted the login from the version of the database that I was trying to connect, and no longer received the 404 page when trying to get to Login. Unfortunately, where one problem ends, another occurs.

We're now getting a different error (below). I'm guessing this has something to do with the differences between how the start page on the MVC site is set up compared to how we have it set up on the current webforms site?

Server Error in '/' Application.
Content with id '5' is of type 'Castle.Proxies.StartPageProxy_1' which does not inherit required type 'EPiServer.Reference.Commerce.Site.Features.Start.Pages.StartPage'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Source Error:


Line 64: private void InitializeLoginViewModel(LoginViewModel viewModel)
Line 65: {
Line 66: StartPage startPage = _contentLoader.Get<StartPage>(ContentReference.StartPage);
Line 67: viewModel.ResetPasswordPage = startPage.ResetPasswordPage;
Line 68: }

Source File: E:\EPiServer.MVC\EPiServer.Reference.Commerce.Site\Features\Login\Controllers\LoginController.cs Line: 66

#195080
Jul 12, 2018 19:27
Vote:
 

You are having diffrent model between your code and your database. That need to be fixed. It is not MVC vs WebForms problem.

#195081
Jul 12, 2018 20:19
Vote:
 

Hi Quan,

Are the models and GUIDs for things like blocks and page types going to have to be the same for everything in order for the content from the database to match up?

Thank you,

Kevin Larsen

#195205
Jul 17, 2018 17:22
Vote:
 

I would say yes. The Guids are very important for the system to determine a type. It might work without matching guids, but that is not a given

#195212
Jul 17, 2018 19:54
Vote:
 

I ended up going back and starting a fresh Alloy MVC site and cleaned it up and made the changes that would be needed for our start page and things are working much better now.  Was able to connect the database without issue and after a few additional things from our old project was able to see everything in the backend.  Will be using the same GUIDs and Models going forward.

Thank you!

#195263
Jul 18, 2018 21:20
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.