I have a "send comment" form, which includes a textarea where user can type up to 400 characters. U need it to be send to my /base and I do it wuth an ajax function. Since I must use a url like http://site.com/var1/var2/var3/var4, I can't send it to the ajax function(it's too long with the user textarea's text) and I get: 414 Request-Uri Too Long.
Another error occurs when the user types characters like ':', '<', '>' that are considered as "special" or "unsafe". When I send those characters I get the status code: 400 Bad Request.
I have to mention that I don't want to postback, so the solution has to be an ajax function that uses a /base function to send the information to the DataBase.
As you're limited to the number of chars on the url, you'd have to revert to using a postback to post the comment or use an update panel (which still does a postback but only refreshes portion of the page). And make sure to check the user's input for spammish data...
You could also post your values to /base. Here is a sample with jQuery:
jQuery:
var url = SWFAddress.getPath(); var baseUrl = location.protocol + '//' + location.host; $.post(baseUrl + '/base/Digibiz/GetHtmlUrl/', { url: encodeURIComponent(url) }, function (htmlUrl) { //do stuff }
/base method:
public static string GetHtmlUrl()
{
//Get the url through a post because it can't be passed as a parameter because it contains slashes which don't work with /base.
string url = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["url"]);
return UmbracoController.GetHtmlUrl(url);
}
Unfortunately, I can't use your suggested method because it's a problem when the user types non-eng characters in explorer, and then what is sent is a strign like "??????"
passing a long url to /base function
hi,
I have a "send comment" form, which includes a textarea where user can type up to 400 characters. U need it to be send to my /base and I do it wuth an ajax function. Since I must use a url like http://site.com/var1/var2/var3/var4, I can't send it to the ajax function(it's too long with the user textarea's text) and I get: 414 Request-Uri Too Long.
Hi Ben,
As you're limited to the number of chars on the url, you'd have to revert to using a postback to post the comment or use an update panel (which still does a postback but only refreshes portion of the page). And make sure to check the user's input for spammish data...
Cheers,
/Dirk
Comment author was deleted
Or simply post params to the base url
/base/var1/var2?tolongvar=blablabla
And then in your base method fetch that param with
HttpContext.Current.Request["tolongvar"]
You could also post your values to /base. Here is a sample with jQuery:
jQuery:
/base method:
This sample is also used here: http://our.umbraco.org/forum/templating/templates-and-document-types/16442-Use-jQuery-to-load-a-page-with-another-template#comment61539
Jeroen
Hi Dirk,
Thank you for your reply. I have to say that those are very bad news for me as I use ajax because the postback takes a lot of time.
Is it good solution for me if I use an external webservice and a "normal" ajax function(type:post, dataType:json) for raching this goal?
Chris and Jeoren,
Unfortunately, I can't use your suggested method because it's a problem when the user types non-eng characters in explorer, and then what is sent is a strign like "??????"
Can you suggest other solutions?
Thank you all.
it seems like the only solution is making a new webservice...
works for me.
is working on a reply...