How can I add mvc.net to an old vb.net site - asp.net

this is my first question. The company I work for uses a pretty large and old vb.net site. We were hoping to integrate mvc.net into the site. I've been following a book "Pro ASP.NET MVC 2 Framework" by Steven Sanderson - and it doesn't seem terrible complicated to merge the 2 systems together.
The breakdown looks like this:
Update build file - add GUIDs to so IDE gives options for mvc files.
Add assembly references for mvc.net.
enable routing. (I need to be sure it still uses the vb.net routing first, then mvc)
Merge web.configs. (Using a new blank mvc.net vb project, also where I got the GUID from)
Add whatever folders and start using mvc.
For reference, we currently use .net 3.5, but our operations team tells me 4.0 should be no problem.
The problem I run into is that the GUID from the blank mvc project doesn't work. When I add them to the older project I get "The project type is not supported by this installation." errors. I'm not very familiar with the project types and I'm not sure how to proceed from here. I've tried several combinations to with no success.
Does anyone know how to where I can get or generate the correct GUIDs to get this working? If anyone has done this, are there any other pitfalls I should watch out for? I have the project copied to another branch, so I'm free to make changes without affecting anything else.
Edit:
These are the GUIDs from our main site project:
{349c5851-65df-11da-9384-00065b846f21};
{F184B08F-C81C-45F6-A57F-5ABD9991F28F}
These are the GUIDs from a new mvc4 project (I'm not picky about MVC2-4)
{E3E379DF-F4C6-4180-9B81-6769533ABE47};
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

I would suggest that you leave the current code base as it is.
You can start all your new development(new modules) in ASP.Net MVC. You can then just integrate this new module in your application. This way you can keep all the regression in respected code bases.
You will face problem only in case of session. If you are having InProc session then it would be little difficult to share. If it is already OutProc then it is easy.

Related

Should i create an Empty Web Application or Web API Web Application template? - VB.net

I wanted to build a VB.net web application using MS Visual Studio 2015. Someone suggested me to create a Web API instead of MVC project if i'm also planning to create a mobile app later on. I may use angularjs in my project so controllers will surely be used, so what should i choose when creating the project in the first place?
Because when i created a web project: File=>New Project=>ASP.net Web Application=>Empty..there are no folders for Controllers, Model, etc. Do i have to create a Controller folder on my own?
Or should i do this: File=>New Project=>ASP.net Web Application=>Web API..? sorry if its a silly question. its just that i'm afraid that if i chose the wrong project now, it'll affect the development later on.
Answer to your question mainly depends on your choice and needs,
for example
In Case of an empty project as name defines you will have nothing else web.config.
Benefits of it:
here you can define, design your own structure. you can either make
it simple 3 tier or you can make it WEBAPI application. it's all up
to you.
however in the case of choosing Webapi template you will have a prebuilt structure which can help you out for initial understanding
https://docs.asp.net/en/latest/tutorials/first-web-api.html
benefits of it
You will get predefine template and structure.
you can utilize of webapi's which further isolate you backend logic from the frontend.
as you are also planning to create the mobile app. and using front end as angular, so in that case, webapi may come handy.
as the whole world is moving towards webapi, so i will recommend you to use it. please refer https://blogs.msdn.microsoft.com/martinkearn/2015/01/05/introduction-to-rest-and-net-web-api/
so down the line it all depend on you if you want to build you application for the stretch and take full control of it regarding structuring backend etc.. then go with empty else go with Microsoft pre-define template
Thanks,
Ajay Kotnala

How to migrate from WebForms to MVC, step by step?

I'm having already existing project (of medium size) that is created using WebForms. Now I have to gradually migrate it to MVC5. I should start section by section, site by site, and at the end to got to the point where it will be fully in MVC.
I'm having intermediate knowledge of MVC and basic/intermediate knowledge of WebForms. I guess these will be the steps:
1.) to create empty MVC5 solution
2.) integrate WebForms project into new MVC5 solution
3.) make WebForms and MVC5 run side by side (make sure that old system works correctly while it's part of MVC5 solution)
4.) modifying WebForms project, section by section (site by site) and converting them one by one to MVC patterns
In theory I think I got the idea, but in the code I'm really not sure how to start the integration. All I did so far is step 1 :)
I have take a look into this link:
Combine ASP.Net MVC with WebForms, but it did helped me a lot since the blog post from #jeroenh maybe can help me in step3 but not in the step2. For step2 I have tried to apply the post from #Matt in the same link, but I end-up with a lot of errors (at his step6) and a lot of effort, so I'm thinking I'm not on the right track.
Are there some posts/tutorials related to this, step by step, that will guide the developers from doing this WebForms and MVC running side by side (but in one project and not in different projects)?

Integrating my database - Separate project or just merge it?

I'm creating a new MVC web application. I've never used MVC before (in asp.net). Anyway, in my last project, I used Code First and Entity Framework to handle my data and I enjoyed using that so I wanted to use it again.
Now, in the last project, I had a separate project/folder for handling the models and contexts, and I just referenced it into my main project. Would doing something like that still be the right choice in an MVC project, or should I just run it from the 'Models' section?
This is the website where I was learning how to implement this:
http://www.codeproject.com/Articles/468777/Code-First-with-Entity-Framework-5-using-MVC4-and
Is there anything wrong with that approach or is it fine?
Nothing wrong.
If your project is not big enough go for it. Having just one project make it simpler though that you must keep the code organized
If your project might get large, then it would be a good choice to have two project or more for different layers and tiers of your application, such that different guys work on their own project.

ASP.NET MVC 3: can I combine C# Razor Views with F# Controllers?

I figure this is a straight forward question, and I think there is a good chance the answer is "yes" (while mixed-language projects are generally not possible, it seems to me that the View Engine gets special treatment). I know I could also try this out pretty easily myself, but for the record, and to save myself some time, I'd like to know if this combination is possible (I've not used ASP.NET MVC or Razor myself yet, I'm considering options for a new project at work).
Edit: I am particularly interested in whether this combination is possible within a single project. Or more specifically whether there are any feature losses using this combination (even if the two project setup is the way to go).
You can definitely mix a C# Razor code with F# controllers. It may be possible to do this in a single project (by modifying the web project to use F#). An easier alternative is to create a standard C# Razor Web project and a separate F# project (containing model and controller code).
I created a Visual Studio template that allows you to do exactly this.
Unfortunatelly, the template is not yet available on Visual Studio Gallery (so you cannot see it from "Online Templates" tab in "New Project" dialog). There is some issue with their upload mechanism, that I'm trying to resolve, so it should hopefully appear there soon. There are also several ASP.NET MVC templates by Daniel Mohl on Visual Studio Gallery, but I'm not sure if any of them uses Razor.

Can Standard .NET CMS systems be made to work with ASP.NET MVC

Has anyone successfully used a CMS developed for standard ASP.NET with ASP.NET MVC?
I currently use Immediacy CMS and it seems to be quite tightly coupled with standard ASP.NET, but I'd really like to start using ASP.NET MVC.
Are there any CMS systems out there directed at MVC?
How could I persuade my employer to move to ASP.NET MVC?
I suggest take a look to Kooboo (kooboo.com), a simple to use but powerful for developers. Well documented API and based upon ASP.NET MVC (of course ;-)
N2 CMS has an example site in ASP.NET MVC that I've been playing around with that works quite nicely - note that the code is now hosted on Google Code.
The problem you've got is that many CMS' already do a lot of "routing" in that the pages you are requesting/editing don't actually exist on disk, but are all in a data store of some kind, and there's an HttpHandler or ISAPI Filter sitting in front of ASP.NET to intercept the requests and work out what should be happening.
I have not personally seen any of the big name CMS systems out there upgraded yet to take advantage of many of the new things the .NET framework offers, let alone start working on the MVC framework.
As with all things, a cost-benefit analysis is the best way to convince your boss to do anything. If you can point how how moving towards the MVC framework is going to make some immediate positives (as well as many long term positives) that can outweigh the costs (in time, energy, and money) in the switchover, then you have succeeded.
ASP.NET and ASP.NET MVC are very different beasts in terms of how you develop applications on top of them. Technically, an ASP.NET MVC application is an ASP.NET application with some generic handler that invokes the core MVC framework.
The ASP.NET MVC framework is also relatively new (1.0 just released last MIX) and so it'll take a while before becoming mainstream.
How you can persuade your boss? Talk to him about the positive sides of ASP.NET MVC, and how it will improve his future business. There's plenty of material available to demonstrate that.
I do a lot of work using Immediacy (I used to work there) and I had thought about doing the same thing a couple of months ago. I think that the main issues would result from things like the plug-in handler, the idoc handler and (if your still using it) the ilink hander.
When you enable things like friendly URLS I think this would cause issues if you had similar named methods in your controller actions.
You may be able use some MVC in your project, I could see it working as an admin add-in but I couldn't see it being used to usefully in the main webroot.
I would think a CMS would have to be built using MVC in mind to get the most benefits from using the pattern, instead of trying to make it work in parallel with a pre-existing system API (limited as it is) and making more work for yourself.

Resources