Hot answers tagged

8

What I ended up doing is registering a single route on pipelines/initialize: <pipelines> <initialize> <processor type="MyFramework.Routing.RegisterVirtualFoldersRoutes, MyFramework" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" /> </initialize> </pipelines> and ...


8

Methods like @Html.Action(), @Html.RenderAction etc. apparently requires a route with the {controller}/{action} pattern (even though it isn't actually relevant from what I can see). The config file Sitecore.Speak.Mvc.config contains such a route. Although the route is Sitecore specific it does contain the {controller}/{route} pattern. However, the ...


7

I've done this before using a wildcard item for the parameter and a custom resolver processor that runs just after the ItemResolver - The ItemResolver should resolve to /sitecore/content/mysite/products/* - so in my custom resolver I know if I'm on that item, parse the Url, take the last segment and store the value somewhere - like Sitecore.Context.Items["...


6

Rather than an item named product, create an item named products that represents the entire collection, and then create a child item named * to represent any individual product. Wildcard items will be resolved with any path that doesn't match an existing item, so if your tree is: /products /products/example /products/* A request to http://example.com/...


6

You can use Sitecore Wildcard item. For that, create an item with name of * inside /Home/Statistics item (/sitecore/content/Home/statistics/*). Remember, the * item (wildcard item) should not have any sibling. And, assign required presentation details to the item to show relevant statistics. Now, when you request the page e.g. http://example.com/statistics/...


5

SitecoreIdentityServer in the URL /identity/login/shell/SitecoreIdentityServer is just an identity provider name which is configured in Sitecore.Owin.Authentication.IdentityServer.config. It should be SitecoreIdentityServer for everyone until we change the config manually for some reasons. So basically you no need to worry about redirection to /identity/...


4

This will be the way the routes get registered when applied by attributes. The correct way to register your own routes with Sitecore is to write a custom initialize pipeline processor and patch it in before the Sitecore InitializeRoutes processor. Take this example from the Habitat project: public class RegisterWebApiRoutes { public void Process(...


4

As stated in the SO answer, the real issue is that without enabling the Sitecore.Speak.MVC.config, there's no route pattern matching just {controller}/{action}. The answer that will solve your problem is that you need to enable a config on the Content Delivery Servers that enable this route. There are a couple ways you can do this: Option 1: Enable ...


3

This issue is solved. For me this issue was only happening for Sitecore 8.2 on a machine with ASP.NET version 4.6 and above. Also issue surfaces when I launched EXM Dashboard or Experience Analytics Dashboard. I had to open a ticket with Sitecore and they helped me with this. Solution: Add the third party dll with MVC or API routes in the ...


3

It needs to create custom routing for calling a controller action method for multisite. Steps are as below: Step 1) Add App_start folder in the Foundation Layer Project. Add a class file in this folder e.g. RegisterWebApiRoutes.cs, use the below code in this class file. public void Process(PipelineArgs args) { RouteTable.Routes.MapRoute(...


3

Absolutely possible to use without routing. The layout service is a simple REST API at its core, and it does not care if it's invoked from a router or not. The sample app's jss-context.service.ts shows the REST call being made. The sitecore-jss-angular package's LayoutService type uses the angular HttpClient to make the call. If you think you'll need ...


3

How about using just a wildcard? Assuming all instances of /product/xxx use the same layout, you'd create a single subpage under it called * and set the renderigns on that item. Then in your Controller Rendering, you'll need to read the product ID off of the the url. Something like: var productID = Sitecore.Web.WebUtil.GetUrlName(0);


3

Longhorn I've handled this by doing a url re-write in IIS to convert your request for a SEO Friendly url to a parameter based one like so: <rule name="Friendly Product Urls"> <match url="^(.*)products/(product)/([0-9]+)" /> <action type="Rewrite" url="{R:1}products/product?id={R:3}" /> </rule> My controller action then picks ...


3

The code looks like it should work. I would make the following changes to just make things a bit more robust: Add a [HttpGet] attribute to the Login action result. It could be that over https the route is hitting the Get action result first, but because it is not limited to Get it will accept Post also. [HttpGet] public ActionResult Login() Check your $...


3

With WebAPI you may define your custom controller routes using Route attribute. The controller below excludes the /sitecore prefix from the URL and accessible as <hostname>/api/my: [RoutePrefix("api/my")] public class MyController : ServicesApiController { [HttpGet] [Route] public string Get() { return DateTime.Now.ToString(); ...


2

As I see it, your options are: Change the routing setup to remove the /sitecore part from the expected route information. Not knowing your code, this could have side effects and would need a thorough regression test. Using your Load Balancer (LB) or Url Rewrite rules, you can rewrite the public Url to remove the /sitecore part, and then route that from the ...


2

I have implemented something similar to this using the wildcard solution. I had a begin request pipeline that fired when an item of a specific type was being hit (the type that my wildcard was). The item had a droplink field and template type field. The droplink pointed to a folder of pages that was in a global location so many sites could reference the same ...


2

The code below is code I reuse constantly. The only caveat is that is the controller is in a different project/library than the route initialization code, strange thing happen. I always keep the controller and initialize code together. Your url would now be http://mysite/api/FindACenterMap Please see this answer while modification of the global.asax is ...


2

Your route pipeline definition should be changed to this one: public class RegisterTestApiRoute { public virtual void Process(PipelineArgs args) { RouteTable.Routes.MapRoute( "testApi", "api/testing/{controller}/{action}" ); } } as MapRoute is meant for "normal" ASP.NET MVC controllers whereas ...


2

Another solution and basically the simplest one is to remove dlls that add custom routes. You need to identify them and remove from your bin folder. You can try to add some suffix to the end of the file to try to identify which one is the "faulty" something like "asssembly.dll.disabled" instead of "asssembly.dll".


1

As an alternative you can write your own processor. For example like you would create a 404 processor, but then let it hook into a Sitecore list where you map url's to external links. Like: public class NotFoundRedirectProcessor: HttpRequestProcessor { public override void Process(HttpRequestArgs args) { if (Sitecore.Context.Item != null || ...


1

It looks like you need to use the JSON.stringify() to pass an object. jQuery.ajax({ type: 'Post', contentType: 'application/json', data: JSON.stringify({ "firstName" : "first", "lastName" : "last" }) url: '/sitecore/api/test/myapi' });


1

If I'm understanding correctly, you're looking to get the result from a controller, and return that through an API controller. The problem with that is that a controller action generally returns an ActionResult object, not just a string of HTML. There are many types of ActionResult that would be hard to handle, or would have to be special-cased, such as ...


1

The reason why you are seeing an empty page (with header and footer) when requesting a faulty id is probably because the code in the rendering that shows your actual content can't find any data and therefor is not showing anything. I see two possible solutions: 1. Custom processor in <httpRequestBegin> In this case you need to move some logic to the ...


1

You will need to have a custom processor in the <httpRequestBegin> which see if the item in the url is valid or not. So, the patch will be as follows: <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <pipelines> <httpRequestBegin> <processor type="YourNamespaceHere, ...


1

I think Sitecore (the .net framework underneath actually) is detecting your "wo" as a language (Wolof - Senegal). There is a setting in Sitecore called Languages.AlwaysStripLanguage. If you would set that to false (patch it) I think your "wo" will also give the 404.


1

You could add your language as a parameter to the route. Something like this: routes.MapRoute("FormsApiWithLanguage", "{languageCode}/api/sitecore/Forms/SubmitForm", new { controller = "Forms", action = "SubmitForm", languageCode = "en" } ); I'm just setting a default language code there with the "en" - now your language code would be passed ...


Only top voted, non community-wiki answers of a minimum length are eligible