When a click the btnLlamadaAjax button tha app show the error: No umbraco document matches the url 'http://www.artc.pe/es/home/noticias/crecimiento-facebook.aspx/call'
When a use a custom aspx page, this page is in th custompages Folder
In this case the ajax call is working. The problem is when the page is a page generated from umbraco.
I know that I can use a Web Services (ASMX) to call a WebMethod or Umbraco /Base , but i would like call a Page WebMethod.
Is it possible?
Thanks
Regards From Lima - Peru
ERROR:
<html><body><h1>Page not found</h1><h3>No umbraco document matches the url 'http://www.artc.pe/es/home/noticias/crecimiento-facebook.aspx/call'</h3><p>umbraco tried this to match it using this xpath query'/root/* [@urlName = "es"]/* [@urlName = "home"]/* [@urlName = "noticias"]/* [@urlName = "crecimiento-facebook"]/* [@urlName = "call"]')</p><p>This page can be replaced with a custom 404 page by adding the id of the umbraco document to show as 404 page in the /config/umbracoSettings.config file. Just add the id to the '/settings/content/errors/error404' element.</p><p>For more information, visit <a href="http://umbraco.org/redir/custom-404">information about custom 404</a> on the umbraco website.</p><p style="border-top: 1px solid #ccc; padding-top: 10px"><small>This page is intentionally left ugly ;-)</small></p></body></html>
I know that I can use Umbraco /Base , but i would like call a Page WebMethod, because a think Umbraco /Base use reflection to call the WebMethod, and it is slower than use the native Jquery Ajax call. Right?
If you're worried about the performance of using reflection then you've got larger problems in your overall site :P.
I haven't tried WebMethods for years for several reasons (which I wont go into here) but when I tried last you couldn't do it because of the way the Umbraco routing engine works.
WebMethod is really just a work around to turn a page into a pesudo-web service but the problem is that the Umbraco routing engine sees the path and thinks that you should be going to a page.
I've never seen a scenario where a WebMethod was the best choice, it always seemed like implementing something in the wrong place.
Umbraco calling Page WebMethod using Jquery Ajax
I am working with Umbraco v 4.5.2
I have a Custom Base Page
public class BasePage : UmbracoDefault
{
[WebMethod]
public static string CallWebMethod()
{
return "Hello Umbraco";
}
}
I updated the default.aspx page to whole pages inherit from my BasePage
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="Artc.Web.BasePage" trace="true" validateRequest="false" %>
I have tried call the CallWebMethod() webmethod from a aspx page generated from umbraco
The crecimiento-facebook.aspx is a page generated from umbraco.
This page have the following code:
<
script src="/scripts/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function Call()
{
$.ajax
(
{
type: "POST",
url: "crecimiento-facebook.aspx/CallWebMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: CallSuccess,
error: MostrarError
}
);
}
function CallSuccess(resultado)
{
alert(resultado.d);
}
function MostrarError(error)
{
alert(error.responseText);
}
</script>
<input id="btnLlamadaAjax" type="button" value="Llamada Ajax" onclick="Call()"/></div>
When a click the btnLlamadaAjax button tha app show the error: No umbraco document matches the url 'http://www.artc.pe/es/home/noticias/crecimiento-facebook.aspx/call'
When a use a custom aspx page, this page is in th custompages Folder
<add key="umbracoReservedPaths" value="~/umbraco,~/install,~/custompages/" />
In this case the ajax call is working. The problem is when the page is a page generated from umbraco.
I know that I can use a Web Services (ASMX) to call a WebMethod or Umbraco /Base , but i would like call a Page WebMethod.
Is it possible?
Thanks
Regards From Lima - Peru
ERROR:
<html><body><h1>Page not found</h1><h3>No umbraco document matches the url 'http://www.artc.pe/es/home/noticias/crecimiento-facebook.aspx/call'</h3><p>umbraco tried this to match it using this xpath query'/root/* [@urlName = "es"]/* [@urlName = "home"]/* [@urlName = "noticias"]/* [@urlName = "crecimiento-facebook"]/* [@urlName = "call"]')</p><p>This page can be replaced with a custom 404 page by adding the id of the umbraco document to show as 404 page in the /config/umbracoSettings.config file. Just add the id to the '/settings/content/errors/error404' element.</p><p>For more information, visit <a href="http://umbraco.org/redir/custom-404">information about custom 404</a> on the umbraco website.</p><p style="border-top: 1px solid #ccc; padding-top: 10px"><small>This page is intentionally left ugly ;-)</small></p></body></html>
Hi Manuel,
I'd probably advise you not to go down that route, and instead look into /base instead
http://our.umbraco.org/wiki/reference/umbraco-base/programming-a-class-for-the-base-system
http://www.cultiv.nl/blog/2010/10/12/using-base-to-create-and-consume-a-json-string
Matt
Hi Matt
Thanks for your answer
I know that I can use Umbraco /Base , but i would like call a Page WebMethod, because a think Umbraco /Base use reflection to call the WebMethod, and it is slower than use the native Jquery Ajax call. Right?
Please, Let me know is a i am wrong.
Manuel
If you're worried about the performance of using reflection then you've got larger problems in your overall site :P.
I haven't tried WebMethods for years for several reasons (which I wont go into here) but when I tried last you couldn't do it because of the way the Umbraco routing engine works.
You're better off using Base or WebServces
+1 for WebService.
In theory it should be possible to add webmethod function into template into script with runat="server tag.
Theory != practice :P
WebMethod is really just a work around to turn a page into a pesudo-web service but the problem is that the Umbraco routing engine sees the path and thinks that you should be going to a page.
I've never seen a scenario where a WebMethod was the best choice, it always seemed like implementing something in the wrong place.
Hi
Thanks for yours answers
Now I am using Base .
I am passing params using url. It is working.
I tried pass params using:
data: "{'nombre':'" + nombre + "','apellidos': '" + apellidos +"' ,'email': '" + email + "','telefono': '" + telefono + "','mensaje': '" + mensaje + "'}",
But didn't work. Why?. I would like use the data parms
$.ajax
(
{
type: "POST",
url: "/Base/ArtcBase/SendEmail/" + nombre + "/" + apellidos + "/" + email + "/" + telefono + "/" + mensaje + ".aspx",
//data: "{'nombre':'" + nombre + "','apellidos': '" + apellidos +"' ,'email': '" + email + "','telefono': '" + telefono + "','mensaje': '" + mensaje + "'}",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: EnviarSuccess,
error: MostrarError
}
);
public
static string SendEmail(string nombre, string apellidos, string email, string telefono, string mensaje)
{
return true;
}
Regards
Manuel
is working on a reply...