Reputation: 4726
I have a VS 2008 web application running on IIS 6. In the web.Config wile there is a section like this:
<location path="public">
<system.web>
<authorization>
<allow users="?"/>
<allow users="*"/>
</authorization>
</system.web>
</location>
I have a user control which is used on numerous pages in various locations to provide content. I want that control to filter content based on the location of the page it is on. For example, if the control is on an aspx page located in the "public" folder as specified in the sample above, I would like certain information to not be displayed.
How can I accomplish this in my codebehind? It may also be that this web.Config setting is completely irrelevant, to this question, you decide. VB or C# are fine, I can translate.
Perhaps something like this? If path.Contains("public") Then filterResults()
Thanks! :)
Upvotes: 1
Views: 117
Reputation: 10400
I would add a public property to the user control called "Mode" OR "ContextUrl" or something to that effect. Then branch logic off of that property. You should also have a 'default' set of logic.
Ultimately, having this behavior dictated by a public property is something that is more intuitive and testable to the "developer" who is interacting with your user control as opposed to something hidden in the controls implementation.
Upvotes: 1