|
1 | 1 | # Verify FormsAuthentication cookie on request through custom attribute
|
2 | 2 | httpModule for verification of FormsAuthentication cookie on request, using a custom attribute.
|
3 | 3 |
|
4 |
| -Currently supported use cases: |
| 4 | +## Currently supported use cases: |
| 5 | + |
| 6 | +### C#: |
| 7 | + |
| 8 | +#### Decorated on a PageMethod or ASP.NET Ajax WebMethod: |
| 9 | + |
5 | 10 | ```csharp
|
6 | 11 | [RequiresAuthentication]
|
7 | 12 | [WebMethod]
|
8 | 13 | public string AjaxMethod() {
|
9 | 14 | ```
|
10 | 15 |
|
| 16 | + |
| 17 | +#### Decorated on a Page, MasterPage or ASP.NET Ajax WebService Class: |
| 18 | +##### Page Class: |
11 | 19 | ```csharp
|
12 | 20 | [RequiresAuthentication]
|
13 | 21 | public partial class WebFormsPage : System.Web.UI.Page
|
14 | 22 | ```
|
| 23 | +##### MasterPage Class: |
| 24 | +```csharp |
| 25 | +[RequiresAuthentication] |
| 26 | +public partial class WebFormsMasterPage : System.Web.UI.MasterPage |
| 27 | +``` |
| 28 | +##### WebService Class: |
| 29 | +```csharp |
| 30 | +[RequiresAuthentication] |
| 31 | +[System.Web.Script.Services.ScriptService()] |
| 32 | +[WebService(Namespace = "http://localhost:8080/")] |
| 33 | +[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
| 34 | +[global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] |
| 35 | +public class AspAjaxWebService : System.Web.Services.WebService |
| 36 | +{ |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +### VB: |
| 43 | + |
| 44 | +#### Decorated on a PageMethod or ASP.NET Ajax WebMethod: |
| 45 | +```vb |
| 46 | +<RequiresAuthentication> |
| 47 | +<WebMethod> |
| 48 | +public function AjaxMethod() as string |
| 49 | +``` |
| 50 | + |
| 51 | +#### Decorated on a Page, MasterPage or ASP.NET Ajax WebService Class |
| 52 | +##### Page Class: |
| 53 | +```vb |
| 54 | +<RequiresAuthentication> |
| 55 | +Partial Class WebFormsPage |
| 56 | + Inherits System.Web.UI.Page |
| 57 | +``` |
| 58 | + |
| 59 | +##### MasterPage Class: |
| 60 | +```vb |
| 61 | +<RequiresAuthentication> |
| 62 | +Partial Class WebFormsMasterPage |
| 63 | + Inherits System.Web.UI.MasterPage |
| 64 | +``` |
| 65 | + |
| 66 | +##### WebService Class: |
| 67 | +```vb |
| 68 | +<RequiresAuthentication> |
| 69 | +<System.Web.Script.Services.ScriptService()> |
| 70 | +<WebService([Namespace]:="http://localhost:8080/")> |
| 71 | +<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> |
| 72 | +<[global].Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> |
| 73 | +Public Class AspAjaxWebService |
| 74 | + Inherits System.Web.Services.WebService |
| 75 | +End Class |
| 76 | +``` |
| 77 | + |
15 | 78 | <br/>
|
16 | 79 | Remember to set the FormsAuthentication cookie!
|
0 commit comments