Convert WebForm VB Web Application to MVC C # Gradually

We currently have a vb web form application, and we want to port it to C # MVC. Instead of completely rewriting, we want to move the project at a time.

I know that it can have a hybrid project with webforms and mvc, as described below:

http://blog.falafel.com/integrating-aspnet-mvc-4-into-existing-web-forms-applications/

But the problem is that the external pages of the web application remain vb / asp.net web forms and when the user clicks on an area, that is, a button that has been rewritten in C # / razor mvc. How to upload / direct user and display razor views in web forms.

Can I visualize the appearance of a razor in web forms?

If I can’t switch to a new tab?

Any ideas how to do this?

thank

+4
source share
1 answer

I am currently working on the same hubryd project where I have a WebForm part and an MVC part.

We are trying to get rid of part of WebForms.

The strategy I am facing is:

  • Get all the logic from WebForms to BL level in your solution.
  • Replace all modal dialogs that do not need feedback results from partial representations of MVC + Razor. This is very easy to do with AJAX. in your interactive WebForm element:

OnClientClick='<%# "showEntityList("+Eval("Id")+"); return false;" %>'

js code that makes an ajax call (I use the jquery dialog behind this function):

function showEntityList(Id) {
    dialogSaveCancel(
        {
            title: "Entity List",
            urlPost: '/ControllerName/ControllerMethodName?id=' + Id,
            callback:
                {
                    success: function (data, textStatus, jqXHR) {
                        var url = 'test';
                        window.location.replace(url);
                    },
                    error: function () { }
                }
        });
};

So, you can get your Razor View in the WebForms part.

  1. , , MVC - reaplace WebForm RazorView.

, js:

function ShowInNewTab(path) {
    window.open(SiteAppRootPath + path, '_blank');
}
0

All Articles