简体   繁体   English

将ASP.NET C#网站作为子网站集成到VB网站

[英]Integrating ASP.NET C# website as subsite to a VB website

I have a ASP.NET 2.0 website created in C# that acts as a completely independent site and I am looking to integrate this into an existing ASP.NET 2.0 website created in VB.NET. 我有一个用C#创建的ASP.NET 2.0网站,它是一个完全独立的网站,我希望将其集成到用VB.NET创建的现有ASP.NET 2.0网站中。 Unfortunately I just don't know much about the server management side of ASP.NET yet so too much I'm unaware of when it comes to IIS configuration etc. Does anyone have any advice as to how I can go about integrating this? 不幸的是,我只是对ASP.NET的服务器管理方面了解不多,但是我却不太了解IIS配置等方面。有人对我如何整合此方面有任何建议吗? Basically I want to host it in a subdirectory from root so when you hit example.com/myindependantsite/ it will pull up my C# site. 基本上,我想将其托管在root用户的子目录中,因此当您访问example.com/myindependantsite/时,它将拉起我的C#网站。

One possible solution I came across mentioned just dropping the project folder into the root directory and setting up that directory as an application virtual directory in IIS? 我遇到的一个可能的解决方案是将项目文件夹放到根目录中,然后将该目录设置为IIS中的应用程序虚拟目录? A few other random questions were small things like would my application relative links (~/for-example.aspx) stay relative to my root subdirectory if it's made into an application virtual directory? 其他一些随机问题是一些小问题,例如,如果将应用程序相对链接(〜/ for-example.aspx)设置为应用程序虚拟目录,该链接是否仍相对于我的根子目录? Just trying to get this running on their site but like I said it's completely independent so want to preserve my websites environment. 只是想让它在他们的网站上运行,但是就像我说的那样,它是完全独立的,因此想保留我的网站环境。 Thanks everyone!! 感谢大家!!

First off, the language doesn't make any difference- they are both .NET, and can live side-by side easily. 首先,该语言没有任何区别-它们都是.NET,并且可以轻松地并存。 Setting it up as a virtual directory may work, depending on assumptions made when developing the C# site. 根据开发C#网站时所做的假设,将其设置为虚拟目录可能会起作用。 Relative links will re-root to the virtual directory, assuming that you make it an application in IIS. 假设您将其设为IIS中的应用程序,则相对链接将重新指向虚拟目录。

The problem you're going to run into by having one site as a sub-application of another site is that the web.config settings will cascade down from the root and they may not be compatible with each other. 将一个站点作为另一个站点的子应用程序会遇到的问题是,web.config设置将从根目录开始向下层叠,并且它们可能彼此不兼容。

Your links will be fine as long as they are made using the ~ notation because that will be relevant to the application root (which you will need to create to maintain the separation you're looking for). 您的链接只要使用~表示法就可以了,因为它们与应用程序根目录相关(您将需要创建该根目录以保持所需的分隔符)。

Your biggest concern is truly going to be the cascade of the web.config and assembly entries there-in. 您真正要担心的是真正的web.config和其中的程序集条目的级联。 If this creates a concern, you will have to separate them completely into different websites or into a different folder structure where neither is dependent on the other. 如果这引起了关注,则必须将它们完全分开到不同的网站或不同的文件夹结构中,而这两个都不依赖于另一个。

Other than that, if you can handle the configuration settings cascading down, then they will be able to coexist within that structure as separate applications as long as you give them independent application pools. 除此之外,如果您可以处理级联的配置设置,则只要您为它们提供独立的应用程序池,它们就可以在该结构中作为单独的应用程序共存。

As Chris said, language doesn't matter. 正如克里斯所说,语言无关紧要。

If the sites are truly different things then it might make more sense to simply add a new third level domain name such as http://theotherstuff.mydomain.com which your c# site will live at. 如果这些站点确实是完全不同的,那么简单地添加一个新的第三级域名(例如http://theotherstuff.mydomain.com)可能会更有意义,您的c#站点将位于该域名。 You could issue a redirect from http://www.mydomain.com/theotherstuff to push users to the other url. 您可以从http://www.mydomain.com/theotherstuff发出重定向,以将用户推送到其他URL。

Among other things this would help keep the web.config's completely separate. 除其他外,这将有助于使web.config完全独立。 As it stands if your two sites work with different frameworks (2.0 vs 4.0) then you are going to run into other issues. 就目前而言,如果您的两个站点使用不同的框架(2.0与4.0),那么您将遇到其他问题。

Can you define how you want to integrate the two sites? 您可以定义如何整合两个站点吗?

As Chris said, since they are both .NET, the language really does not matter. 正如克里斯所说,由于它们都是.NET,因此语言确实无关紧要。 As stated you could just create a folder in the root of the current site, add the code for your C# site to that, and create it as a virtual directory. 如前所述,您可以仅在当前站点的根目录中创建一个文件夹,向其中添加C#站点的代码,然后将其创建为虚拟目录。 It would be accessed like this: www.MyDomain.com/VirtualFolderName it would act as its own independent site. 可以通过以下方式访问它:www.MyDomain.com/VirtualFolderName它将充当其自己的独立站点。

As far as relative links, if I am remembering correctly they should evaluate from the virtual folder domain, so ~/example.aspx in your virtual folder should point to www.MyDomain.com/VirtualFolderName/example.aspx. 至于相对链接,如果我没有记错的话,它们应该从虚拟文件夹域中进行评估,因此虚拟文件夹中的〜/ example.aspx应该指向www.MyDomain.com/VirtualFolderName/example.aspx。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM