November Happy Hour will be moved to Thursday December 5th.

How to get correct route url in dojo component?

Vote:
 

Dear EPIServer Team,

please help.

I want to get the partial view in dojo component. The issue is with the request url.

When i try to use(DynamicImages is a controller and Images as an action)

$.post("DynamicImages/Images", { json: jsonData }, function (value) {

var fieldContainer = $('.imagesContainer');

the request is sent to incorrect url: http://localhost:83/DynamicImages/Images,

not to http://localhost:83/MySite/DynamicImages/Images.

I found epi.routes.getActionPath, but how to use these method to get the correct url?

How to setup parameters?

 var url = ({
                    moduleArea: "CMS", // ????
                    controller: "DynamicImages",
                    action: "Images",                   
                });

The result is  /MySite/EPiServer/CMS/DynamicImages/Images

but I need  /MySite/DynamicImages/Images

What should I use to generate correct url to the action?

Thank you inadvance.

#75850
Oct 08, 2013 18:53
Vote:
 

The route configuration for the epi/routes helper is generated from the module.config settings. You can probably achieve what you want by adding the following the module.config in the site.

<module routeBasePath="~/">
  <routes>
    <route url="{controller}/{action}/{id}" />
  </routes>
</module>

and the getting the route path using

routes.getActionPath({
    moduleArea: "App", 
    controller: DynamicImages",
    action: "Images"
});

 

 

#75855
Oct 09, 2013 9:23
Vote:
 

Thank you very much for the aswer. It helped.

But if I use the parameter moduleArea: "App" , I get the url "MySite/DynamicImages/Images?moduleArea=App"

How to setup the route without the moduleArea = App ?

How to get the list of the available moduleArea?

Please, help.

 P.S. I used the epi.routes.getActionPath({controller: "DynamicImages",action: "Images"}, "{controller}/{action}"), returned the "DynamicImages/Images"

but how to return clear "MySite/DynamicImages/Images"?

#75909
Edited, Oct 10, 2013 18:35
Vote:
 

Hmm, the getActionPath helper is primarily intended for resolving routes to the different modules, and therefore the module area is always a part of the route. And since the logic in the helper is quite simple, all parameters that can't be substituted in the path will be appended as query parameters.

For the available areas you can look at 

epi.routes.registeredRoutes
#75964
Oct 14, 2013 9:27
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.