开发者

ASP.Net Website, I'm exposing functionality externally how can I limit duplicate code?

开发者 https://www.devze.com 2023-02-12 13:12 出处:网络
Some of my clients are off of our internal network and I\'m going to be exposing a few reports to the internet. This means that I\'ll have 2 separate sites one with admin functions and reports on our

Some of my clients are off of our internal network and I'm going to be exposing a few reports to the internet. This means that I'll have 2 separate sites one with admin functions and reports on our intranet and one with just reports exposed to the internet.

The pages that I'll be duplicating are fairly simple. Asp chart controls with a few other fields for choosing time span, size of report, relevant filters etc.

What are so开发者_如何学编程me ways to reduce the amount of duplicate code in 2 nearly identical ASP .Net websites?

Compiling UserControls into libraries? CSS files in a resource file? Put app_code somewhere else? How would I do any of these if they are possible?

My websites will be on completely different web servers and will be sharing the same SQL Server 2005 DB.


I think you've already answered your question. Move some of the shared logic into a separate class library which you can re-use on multiple sites. Try to avoid App_Code where possible, its a special feature of ASP.NET that dynamically compiles a specific folder into its own assembly. If you are sharing App_Code, it means duplicate code between sites.

Having a shared code base greatly improves maintainability and testability.


Assuming that you want to remove entire pages, and not parts of pages, you could probably handle this as a web.config issue and just have two installations.

For example, if you had an Admin folder, and placed a web.config file inside of the Admin folder, such as:

<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <system.web>
        <authorization>
            <deny users="*" />
        </authorization>
    </system.web>
</configuration>

It would deny access to everything within the Admin folder to all users (I think). You could do with with <location> elements in your main web.config, but that's a little more tedious.

0

精彩评论

暂无评论...
验证码 换一张
取 消