How to integrate WebSockets on top of a classic AS

2019-03-21 06:21发布

问题:

In one of my projects, I have a very active classic ASP site with a requirement to integrate live event-based feeds as part of the existing UI. There is a plan to upgrade the site architecture to either MVC or MVP in the future, but this new feature must be implemented in the meanwhile.

I have decided to go with a WebSocket approach for this, as this is ultimately what we will want to use in the future, and rebuilding this doesn't make sense. The question is, how to integrate this with the classic ASP "architecture"?

The site already implements the jQuery library, and was hoping to leverage jQuery's capabilities to create those streamed sections on a given page.

The current req's ask for this news feed to exist on every page. Thus, loading a new page will re-render the news feed, and should kick of from where it left on the last page. For this, I'm guessing a position indicator will need to be read (session variable I'm guessing).

Anyhow, those are the requirements. I was thinking of wrapping the the entire existing classic ASP site inside a MVC or MVP (C#/.Net) project to allow us to begin swapping out legacy features as they are developed, such as this one.

I would like to get some advice on some recommended approaches for this scenario.

Thanks.

回答1:

I would do a SignalR app and integrate it in you old app.

It's easy to integrate ASP classic with ASP.net MVC. Just mix the projects and exclude *.asp from the routes

routes.IgnoreRoute("{resource}.asp/{*pathInfo}");

You will have some trouble in the root (/), but you can sort it with a redirect.

For a mixed authentication (if you need it) you will need to write your own authentication in MVC to use the same auth cookie that you use in Classic ASP. I've done this in the past with success.