如何将ASP.NET网站分解为可以启用/禁用的模块?
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

I have an ASP.NET website with some independent sections. I need a way to turn on/off the different sections (each section is in it's own directory) based on the user selection. How can I prevent the users from accessing sections that are turned off?

#0

The solution I ended up using was to make a new class ModulePage that inherited Page. In the OnInit it would check an Abstract property I added IxModule to see if that that module was turned on or off, if it was on the page will display and if it is not the user is redirected to another page. Each page in each module has to be change to inherit ModulePage and then just specify the IxModule value. It is working very well.

#1

You could look for a specific web.config app setting for each section. Each section would need a web.config setting with a sectionID app setting element.

If your using master pages, just do a check in the master's on PageLoad and check to see if the user has access to the sectionID store in the config setting. Store the section IDs that the current user has access to in the session or a cookie or something (not sure what type of security your looking for). Have one global function to lookup the app setting from the web.config. Depending on which page is calling it (from which directory) you will get the specific section's ID.

If the user does not have access redirect or show a message or something.

#2

you can require a log-in for those pages. I'm not sure if that's what you want.

推荐文章

Webassembly for C, Rust, Go, and C# in 45 Minutes

Webassembly for C, Rust, Go, and C# in 45 Minutes

推荐文章

开发第一次简单的Windows应用程序需要什么IDE?

开发第一次简单的Windows应用程序需要什么IDE?

推荐文章

Linux/HPUX中的正则表达式

Linux/HPUX中的正则表达式

推荐文章

【angular】遮罩效果实现

【angular】遮罩效果实现

推荐文章

为什么运行“apachectl-k start”不起作用,但是“sudo apachectl-k start”起作用?

为什么运行“apachectl-k start”不起作用,但是“sudo apachectl-k start”起作用?

推荐文章

ASP连接ACCESS数据库代码

ASP连接ACCESS数据库代码

推荐文章

You probably shouldn’t be using Kubernetes for your new startup

You probably shouldn’t be using Kubernetes for your new startup

推荐文章

如何重写包含GET变量的url?

如何重写包含GET变量的url?

推荐文章

Bootstrap框架----多条记录双文本(List)添加

Bootstrap框架----多条记录双文本(List)添加

推荐文章

哪里是Drupal主题制作的好指南?

哪里是Drupal主题制作的好指南?

推荐文章

在Rails上,除了<%=%>标签之外,还有其他输出内容的方法吗?

在Rails上,除了标签之外,还有其他输出内容的方法吗?

推荐文章

完全卸载VS2005/VS2008的步骤

完全卸载VS2005/VS2008的步骤

推荐文章

“apachectl”代表什么?为什么不只是“阿帕奇”?

“apachectl”代表什么?为什么不只是“阿帕奇”?

推荐文章

控制自定义控件的呈现

控制自定义控件的呈现

推荐文章

使用实体(及其主键)作为另一个实体的Id

使用实体(及其主键)作为另一个实体的Id

推荐文章

Technical Jargon: REST, API, Endpoints, Monolith, Microservices and Serverless

Technical Jargon: REST, API, Endpoints, Monolith, Microservices and Serverless