网站在一个网站与ASP。NET MVC

时间:2023-01-17 09:17:36

I've searched for an answer to this and I've come up with only two possibilities, both of which I'm not terribly keen on.

我一直在寻找答案,但我只想到了两种可能性,这两种可能性我都不太喜欢。

I have an existing ASP.NET MVC application that we are going to add a module to. This module could also be shared with another product that we have since it covers a lot of common ground. I don't want to have to rewrite this module (even just the UI part) for two separate websites so my initial thought was that we just develop it as a stand-alone site (and since our product suite supports single sign-on across the suite there would be no issues with having to log in again to the new site). However, I was told that it must look like it is part of the existing site, it must sit inside its own tab (the master page has tabs to show you what section of the site you are in) as that is how it is being marketed - an integrated component of the existing product.

我有一个现有的ASP。NET MVC应用程序,我们要添加一个模块。这个模块也可以与我们拥有的另一个产品共享,因为它涵盖了许多共同的领域。我不想要重写这个模块(甚至只是UI部分)两个独立的网站,所以我的第一个想法是:我们只是开发它作为一个独立的社交网站(因为我们整个套件产品套件支持单点登录就不会有问题需要再次登录新网站)。然而,有人告诉我,它必须看起来是现有网站的一部分,它必须位于自己的标签(主页选项卡显示你站点的哪些部分),它是如何被销售,现有产品的一个集成组件。

So, I was thinking of how to get this site to sit inside the tab of the existing site.

所以,我在考虑如何让这个站点位于现有站点的选项卡中。

I thought the easiest thing would just be an iframe. We've already got an iframe on another tab (although its part of the same project - some legacy web forms stuff that rely on a third party control that's incompatible with MVC) and it works... up to a point (It's actually rather an ugly solution and the plan for the next release gets rid of it). I'd rather not do that again.

我认为最简单的就是iframe。我们已经在另一个选项卡上有了一个iframe(尽管它是同一个项目的一部分——一些依赖于与MVC不兼容的第三方控件的遗留web表单),而且它可以工作……在某种程度上(它实际上是一个相当丑陋的解决方案,下一个版本的计划将它去掉)。我不想再那样做了。

The other thought was that inside the tab's content area just have a div that I can replace the content using AJAX calls as the user progresses through the workings of this new module so it all looks like it is one seamless site. Again, that fills me with dread as I don't think it will work very well... and certainly we'll lose out in areas such as Google Analytics (we'd either lose completely, or we'd have to hand craft bits) and allowing users to bookmark pages (the only URL they'd see is the first one when they open the tab as everything after that is made up of AJAX calls.

另一种想法是,在选项卡的内容区域内只有一个div,我可以使用AJAX调用替换内容,以便用户在这个新模块的工作过程中使用它,使它看起来像一个无缝的站点。同样,这让我充满了恐惧,因为我认为它不会很好地工作……当然我们会失去在谷歌分析等领域(我们完全失去,或者我们必须工艺品比特)和允许用户书签页面(唯一的URL时,他们会看到是第一个打开的选项卡,之后的一切都是由AJAX调用。

Does anyone have any suggestions on how to pursue this further? Is there any way to have the first ASP.NET MVC application supply the master pages that the second will use? Or is there a similar mechanism in reverse where I can get the first ASP.NET MVC application to use the second as a provider of content into the firsts master pages?

有没有人提出进一步的建议?有没有办法有第一个ASP。NET MVC应用程序提供第二个将要使用的母版页吗?或者有没有类似的机制,我可以得到第一个ASP。NET MVC应用程序使用第二个作为内容的提供者进入第一页?

Or are my realistic options IFrame or AJAX calls?

或者我的实际选项是IFrame还是AJAX调用?

2 个解决方案

#1


1  

Colin,

科林,

I have a very similar requirement to yours with an additional need to run both sites in the same app pool. I have actually been able to come up with a proof of concept using portable areas. Not super elegant, but i believe it will do the trick.

我和你的要求非常相似,需要在同一个应用程序池中运行两个站点。事实上,我已经能够提出一个使用便携式区域的概念证明。不太优雅,但我相信它会有效果。

Please do let me know if you find a better way.

如果你找到更好的方法,请告诉我。

#2


0  

Another option would be to create the controller and logic for the shared module in it's own library. ASP.Net MVC applications will handle controllers being in separate libraries just fine.

另一个选项是为共享模块在它自己的库中创建控制器和逻辑。ASP。Net MVC应用程序可以处理独立库中的控制器。

The drawback is that any application using this 'shared' module must have it's own views, meaning that you will have to duplicate the views and maintain these separately, but at least you won't be duplicating controller logic.

缺点是任何使用这个“共享”模块的应用程序都必须有自己的视图,这意味着您必须复制视图并分别维护它们,但至少您不会复制控制器逻辑。

This is what I have done in a similar scenario. I did have a look at at including some compiled views in the 'shared library' as per this example, but because you couldn't really included scripts and images it didn't seem worth the effort.

这是我在类似场景中所做的。根据这个例子,我确实研究过在“共享库”中包含一些已编译的视图,但是因为您不能真正包含脚本和图像,所以看起来不值得这么做。

#1


1  

Colin,

科林,

I have a very similar requirement to yours with an additional need to run both sites in the same app pool. I have actually been able to come up with a proof of concept using portable areas. Not super elegant, but i believe it will do the trick.

我和你的要求非常相似,需要在同一个应用程序池中运行两个站点。事实上,我已经能够提出一个使用便携式区域的概念证明。不太优雅,但我相信它会有效果。

Please do let me know if you find a better way.

如果你找到更好的方法,请告诉我。

#2


0  

Another option would be to create the controller and logic for the shared module in it's own library. ASP.Net MVC applications will handle controllers being in separate libraries just fine.

另一个选项是为共享模块在它自己的库中创建控制器和逻辑。ASP。Net MVC应用程序可以处理独立库中的控制器。

The drawback is that any application using this 'shared' module must have it's own views, meaning that you will have to duplicate the views and maintain these separately, but at least you won't be duplicating controller logic.

缺点是任何使用这个“共享”模块的应用程序都必须有自己的视图,这意味着您必须复制视图并分别维护它们,但至少您不会复制控制器逻辑。

This is what I have done in a similar scenario. I did have a look at at including some compiled views in the 'shared library' as per this example, but because you couldn't really included scripts and images it didn't seem worth the effort.

这是我在类似场景中所做的。根据这个例子,我确实研究过在“共享库”中包含一些已编译的视图,但是因为您不能真正包含脚本和图像,所以看起来不值得这么做。