none
Authentication for single page in asp.net web form application RRS feed

  • Question

  • Hello,

    I am creating a ASP.NET web form application in .Net framework 4.6. The code behind used is C#. I have multiple pages in the application, but according to the requirement, there will be one page called "Report.aspx" which should be accessible only to restricted users. All the other pages should be accessible to everyone. 

    So we will be keeping anonymous access in IIS to the application folder. Now the issue is I don't understand how to create a login page for only single page inside the application which will be triggered if the Report page will be triggered.

    Can someone kindly provide an idea or any link which can be referred to perform this action. I will be quite thankful if someone can provide the ideal code to perform this implementation. Kindly let me know if any additional details are necessary.

    Thanks in advance!


    Best Regards, Chetan Navale | Atos India | chetan.navale@hotmail.co.in | 91-9373364792


    Saturday, October 21, 2017 10:36 AM

All replies

  •  

    I am creating a ASP.NET web form application in .Net framework 4.6. The code behind used is C#. I have multiple pages in the application, but according to the requirement, there will be one page called "Report.aspx" which should be accessible only to restricted users. All the other pages should be accessible to everyone

    I kind of cringe when you say code behind file that tells me that you are going to tightly couple everything in all forms in the code behind file -- data access and everything else, instead of implementing SoC or SoD by using a UI design pattern like Model View Presenter.

    https://www.codeproject.com/Articles/228214/Understanding-Basics-of-UI-Design-Pattern-MVC-MVP

    https://lostechies.com/derekgreer/2008/11/23/model-view-presenter-styles/

    The blow is where I learned MVP many years ago, which I have applied to ASP.NET and Windows form based solutions.

    http://polymorphicpodcast.com/shows/mv-patterns/

    The above show creates a classlib project for the Presenter. But you can just use a folder called Presenters in the UI project and put the Presenters there.

    The show uses MVP differently, as opposed that each event at the form can have a corresponding event in the presenter, like Form_Load calls Presenter.Form_Load(). 

    So we will be keeping anonymous access in IIS to the application folder. Now the issue is I don't understand how to create a login page for only single page inside the application which will be triggered if the Report page will be triggered.

    For ASP.NET Web form on a single page authentication, I have never seen it. It's either all or nothing with the login that I have seen.

    This could easily be done with an ASP.NET MVC solution where the MVC controller for the page can use the [Authorize] attribute for a singe action method that would challenge the user for logon credentials.

    The only thing that I see that can work is the report thing is its own stand alone site with IIS authentication, and you transfer control over to it from the other Web application.

    You can ask over in the ASP.NET forums.

    http://forums.asp.net/

    Saturday, October 21, 2017 1:09 PM
  • Dear DA924X,

    Thank you for your response and ideas provided. But unfortunately I doubt I can implement Model View in ASP.NET WebForms application and also if I add it how to integrate it with the code behind pages.

    But Thank you once again for your efforts and feedback. As per your last suggestion I will post this on ASP.NET forum.

     


    Best Regards, Chetan Navale | Atos India | chetan.navale@hotmail.co.in | 91-9373364792

    Sunday, October 22, 2017 2:38 PM
  • Thank you for your response and ideas provided. But unfortunately I doubt I can implement Model View in ASP.NET WebForms application and also if I add it how to integrate it with the code behind pages.

    I put it there right in front of you, below. I leaned MVP back in like 2008 well before I got to MS's version of ASP.NET MVC.

    http://polymorphicpodcast.com/shows/mv-patterns/

    It's up to you to watch the tutorial shows and learn about how to use Separation of Concerns  or Separation of Duty in using MVP with the UI Web forms.

    Of course you have to have basic Object Oriented Programming  knowledge and understand that the responsibility shifts from the code behind file to the MVP Presenter with events on the code behind file, like a button-click() event and all the code in the event is moved to the Presenter.

    The codebehind button-click() event for the form calls its like named  Presenter.Button_Click() method.

    It doesn't take a rocket scientist to figure it out. 

    In essence, the Web form just becomes a dumb form, and it's the Presenter that has the control.

    Sunday, October 22, 2017 4:31 PM
  • Hi Navale Chetan,

    Thank you for posting here.

    According to your question is more related to ASP.NET, you could post a new thread in ASP.NET forum for suitable support.

    This forum discusses and ask the C# programming language, IDE, libraries, samples and tools. If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, October 24, 2017 6:10 AM