<html>
<head>
<title>This type of page is not served.</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>This type of page is not served.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>The type of page you have requested is not served because it has been explicitly forbidden. Please review the URL below and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/CS.aspx.cs/PopulateCountries<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.1882; ASP.NET Version:2.0.50727.1887
</font>
</body>
</html>
<!--
[HttpException]: Path '/CS.aspx.cs/PopulateCountries' is forbidden.
at System.Web.HttpForbiddenHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
The URL cannot have ".cs" in the end. ".cs" pages are only for the server and are never served. You have to change it to just ".aspx" or ".asmx" (for web services).
Also, the web service should have [ScriptService] attribute.
logno
Member
138 Points
194 Posts
Getting error using json
Dec 09, 2010 05:24 PM|LINK
I am trying to call webservice method using JSON.
my code is as follows
<script src="jquery-1.3.2.min.js" type ="text/javascript" ></script> <script type ="text/javascript" > var pageUrl = '<%=ResolveUrl("~/CS.aspx")%>' function PopulateContinents() { $("#<%=ddlCountries.ClientID%>").attr("disabled", "disabled"); $("#<%=ddlCities.ClientID%>").attr("disabled", "disabled"); if ($('#<%=ddlContinents.ClientID%>').val() == "0") { $('#<%=ddlCountries.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>'); $('#<%=ddlCities.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>'); } else { $('#<%=ddlCountries.ClientID %>').empty().append('<option selected="selected" value="0">Loading...</option>'); $.ajax({ type: "POST", url: "CS.aspx.cs/PopulateCountries", data: "()" , contentType: "application/json; charset=utf-8", timeout: 10000, dataType: "json", success: OnCountriesPopulated, error: function(xhr) {if (!error) return; if (xhr.responseText) {var err = JSON2.parse(xhr.responseText); if (err)error(err); else error( { Message: "Unknown server error." })} return;}, failure: function(response) { alert(response.d); } }); } }But am getting error like this:
<html> <head> <title>This type of page is not served.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>This type of page is not served.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>The type of page you have requested is not served because it has been explicitly forbidden. Please review the URL below and make sure that it is spelled correctly. <br><br> <b> Requested URL: </b>/CS.aspx.cs/PopulateCountries<br><br> <hr width=100% size=1 color=silver> <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.1882; ASP.NET Version:2.0.50727.1887 </font> </body> </html> <!-- [HttpException]: Path '/CS.aspx.cs/PopulateCountries' is forbidden. at System.Web.HttpForbiddenHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->how to overcome this problem?
ajax json
worldspawn[]
Contributor
6081 Points
1336 Posts
Re: Getting error using json
Dec 09, 2010 09:30 PM|LINK
You did not use your pageUrl variable. You've set the url to "CS.aspx.cs". You can't serve a .cs file. Only an aspx page.
Also an aspx page isn't really a webservice.
"Wise man say 'forgiveness is divine, but never pay full price for late pizza." - TMNT
software development
sachingusain
Star
8786 Points
1702 Posts
Re: Getting error using json
Dec 09, 2010 11:28 PM|LINK
The URL cannot have ".cs" in the end. ".cs" pages are only for the server and are never served. You have to change it to just ".aspx" or ".asmx" (for web services).
Also, the web service should have [ScriptService] attribute.
http://msdn.microsoft.com/en-us/library/system.web.script.services.scriptserviceattribute.aspx
Thanks.
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: Getting error using json
Dec 10, 2010 07:00 AM|LINK
Hi Logno,
I have already mentioned the reason on your other post
http://forums.asp.net/t/1631432.aspx
logno
Member
138 Points
194 Posts
Re: Getting error using json
Dec 10, 2010 12:13 PM|LINK
url:
"/CS.aspx/PopulateCountries", i rewrite that line but still am facing the same error status.sachingusain
Star
8786 Points
1702 Posts
Re: Getting error using json
Dec 10, 2010 02:03 PM|LINK
Do you have ScriptService attribute on your web service as I mentioned in my earlier post?
Thanks.
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: Getting error using json
Dec 10, 2010 02:20 PM|LINK
Cross check again the extension you are calling. Show the view source of your page.
gt1329a
All-Star
15377 Points
2501 Posts
ASPInsiders
MVP
Re: Getting error using json
Dec 10, 2010 08:30 PM|LINK
In addition to checking for a [ScriptService] attribute on your page method, also make sure it's "static".
Also, your $.ajax() call's data parameter needs to be "{}", not "()".
A guide to combining jQuery and ASP.NET: jQuery for the ASP.NET developer
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: Getting error using json
Dec 11, 2010 06:44 AM|LINK
Ahh yes Dave, that should be consider too , I told him the same to him on his other post too
http://forums.asp.net/t/1631432.aspx
So summarizing all:
logno
Member
138 Points
194 Posts
Re: Getting error using json
Dec 14, 2010 12:57 PM|LINK
Still am getting error.
Web method not at all invoked.
If any one has the code please share me.