Click here to Skip to main content
15,558,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have the Following Code in Jquery:
function CheckSession() {
               debugger;
               $.ajax({
                   url: 'Site.Master/CheckSession',
                   type: 'POST',
                   contentType: 'application/json; charset=utf-8',
                   dataType: "json",
                   success: function (result) {
                       debugger;
                       if (result.d != '') {
                       }
                   },
                   error: function (error) {
                       alert(error.responseText);
                   },
                   async: false
               });
           };


i am getting the error as follows:
post http://localhost:49669/kaizen2g/site.master/checksession 403(forbidden)

In Code Behind Site.master page I have this:
C#
[WebMethod]
       public void CheckSession()
       {
           if (Session[KaizenConstants.CURRENTLOGGEDINUSER] == null)
           {
               Response.Redirect("Login.aspx");
           }
       }


why is it so ??
how to solve it??
Thanks
Harshal
Posted

1 solution

Master pages have no life of there own. Every method/property of a master page is merged with the real page using it. It includes WebMethod too...

Site.Master code:
C#
[WebMethod]
public static void CheckSession()
{
  // ...
}

Portal.aspx markup:
ASP.NET
<%@ Page Language="C#" MasterPageFile="Site.Master" CodeBehind="Portal.aspx.cs" Inherits="Portal" %>

You can call CheckSession like this:
JavaScript
$.ajax({
  url: 'Portal.aspx/CheckSession',
  type: 'POST',
  ...
 
Share this answer
 
v2
Comments
R Harshal 6-May-14 12:49pm    
I already used it ..why its not working .Please let me know .i cant get you.
Thanks
harshal
R Harshal 6-May-14 12:52pm    
its give me the error ..Please guide me.
post http://localhost:49669/kaizen2g/site.master/checksession 500(internal Server Error)
Kornfeld Eliyahu Peter 6-May-14 13:46pm    
See updated solution...
R Harshal 7-May-14 5:40am    
I already added
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Kaizen2GChartReport.aspx.cs" Inherits="Kaizen.UI.WEB.Kaizen2GChartReport"
EnableEventValidation="false" %>

but then too i am getting the error :
post http://localhost:49669/kaizen2g/site.master/checksession 500(internal Server Error)

Please help me .
thanks
harshal
Kornfeld Eliyahu Peter 7-May-14 5:43am    
You does not read what I wrote...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900