Developer forum

Forum » Templates » Server:Request.ajax: in Razor

Server:Request.ajax: in Razor

Dmitrij Jazel
Reply

Hej Guys,

I was wondering how do you do something like this in Razor?

<!--@If Defined(Server:Request.ajax)-->
<xml>XML content here</xml>
<!--@EndIf(Server:Request.ajax)-->
 
<!--@If Not Defined(Server:Request.ajax)-->
<div>HTML content here</div>
<!--@EndIf(Server:Request.ajax)-->

 

 


Replies

 
Mikkel Ricky
Reply

I've just added some useful info on this in our Razor wiki: https://github.com/dynamicweb/razor/wiki/From-Dynamicweb-HTML-to-Razor#serverrequest

Best regards,
Mikkel

 
Dmitrij Jazel
Reply

Hej Mikkel,

Thanks allot for the post :-)

This is what I am trying to do:

Trying to make a ajax request one like here: http://websiteudvikler.dk/post/howto-implement-an-ajax-based-shopping-experience-in-dynamicweb-ecommerce.html

Attempt detecting Ajax like this:

var aj = System.Web.HttpContext.Current.Request["ajax"];
var ServerRequestAjax = System.Web.HttpContext.Current.Request["Server:Request.ajax"];

and trying to detect if this request is Ajax, format the content specifically for this request. (so that I could pass only what I need in Ajax return html)

 

When I am attempt detecting Ajax, in my case aj and ServerRequestAjax are null

 

You must be logged in to post in the forum