-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to interpret a result of custom url resolver as MVC url #392
Comments
In general, I don't recommend using a custom URL resolver. The only use case this makes sense is when you want Unfortunately, there were some problems in the initial 4.x releases of That said, there are 2 ways to address this if you must go down this road:
|
Thank you, Shad. I'm already going to first way with Integration between This data extracted by my implementation of And finally So, if there some another place inside |
Oops, I misspoke before. You should subclass The
As the data loaded from any There is a demo showing how to interact with the user's session. While that is not exactly what you want, it does demonstrate an approach you can use to interact with a different part of the In the demo, there is a custom URL resolver because it needs a way to ignore the data from session state when building the URL. However, if your use case does not have any extra data that has nothing to do with building the URL you likely won't need a custom URL resolver. As for the matching, there are 2 different strategies - one to one and one to many, and there is a post about it here. |
Well. I decide to keep my first solution with
public class MySiteMapNodeUrlResolver : SiteMapNodeUrlResolver
{
public MySiteMapNodeUrlResolver(IMvcContextFactory mvcContextFactory, IUrlPath urlPath)
: base(mvcContextFactory, urlPath)
{
}
protected override RequestContext CreateRequestContext(ISiteMapNode node, TextWriter writer)
{
var context = base.CreateRequestContext(node, writer);
if (node.Attributes["MvcCodeRouting.RouteContext"] != null)
context.RouteData.DataTokens["MvcCodeRouting.RouteContext"] = node.Attributes["MvcCodeRouting.RouteContext"];
return context;
}
} |
Ivv83, care to share your full implementation for solving this? I find myself in the very same situation...! |
Hello, anve. Which implementation you need? Full integration sample with MvcCodeRouting? Or solution for this issue? |
Hi! I do use MvcCodeRouting together with MvcSitemapProvider and suffer from the same problem. The node's URL doesn't resolve correctly, which I believe is due to missing out on the MvcCodeRouting data in RouteData.DataTokens, not being picked up by the default Url Resolver. What I'm looking for, I guess, is your subclass of RequestCacheableSiteMap (.AddNodeInternal), as well as the custom ISiteMapNodeUrlResolver. And ReflectionSiteMapNodeProvider as well :) I guess I'll have to setup MvcSiteMapProvider with an external DI (structuremap already in place in the project in general) in order to get those custom types/overrides in place, right? If so, anything special to put in the DI configuration module (e.g. MvcSiteMapProviderRegistry or similar)? Thanks for your help! |
Welcome to my repo! You should consider, that:
|
Much appreciated! With some minor adjustments to fit this into structuremap, this was exactly was I was looking for and now everything behaves correctly! |
Thanks for providing a working demo. I was able to reverse-engineer it and make the default URL resolver provide the missing piece required by https://github.com/maartenba/MvcSiteMapProvider/tree/dev It also occurred to me that there could be deeper integration with My thought is to create another The There would also need to be an Thoughts? Would you be interested in contributing? |
@NightOwl888, thank you for efforts! I just submit updates to the demo application. With deep integration with
|
Exception is because you didn't include the line to exclude
No. I am thinking we can for the most part use the same conventions they do. Whether or not we have a reference to the project, .NET reflection is involved with getting attributes, so it is better not to reference the project. There is an option when using reflection to get the type based on a string representation of the name without actually checking if the library is referenced (I used that technique here). If the type doesn't exist, you just get a null result. Since nodes only load periodically, I am not to worried about being a little heavy on reflection.
Yes. It is a good thing you brought it up because the XML file owns the root node when enabled. However, there is an option called The bigger question is whether or not it should be used with the Of course, the default settings shouldn't change from the way they are now. The internal DI container will need these new configurations built in. External DI people will need to follow a document to enable MvcCodeRouting.
I don't think so, but maybe. I checked and everything seemed fine, but I am no expert on all of the different configurations MvcCodeRouting supports. The
Probably moot. One of the options on the table right now is to let MvcSiteMapProvider be phased out with MVC5 and create a new design for DNX core. But most likely we will come up with some option for users to make the switch to ASP.NET 5 first before working on a new version (probably not named MvcSiteMapProvider). There will still be a need for MVC4 and 5 support for another 2-3 years because the leap onto the new platform is a big one. It is almost as big of a leap as from VB6 to .NET was :). I made one attempt to wrap the new ASP.NET 5 Context types into the old interfaces, but there are still a few incompatibilities that are preventing a build. The release today addressed some of those incompatibilities. Anyway, perhaps the new design could include something like MvcCodeRouting so everything "just works" with little or no configuration (and lots of conventions). Of course, there should be a way to disable the hierarchical controller part, but it sounds like a reasonable default to me. Also, the changes to the routing infrastructure are relatively minor. I think MvcCodeRouting will have an easier time supporting DNX core than we will. |
Hello everyone!
I work under integration between MvcSiteMapProvider and MvcCodeRouting projects. This is technically available because your library has very good architecture based on the dependency injection pattern. So, my respects to you! :)
I met one issue, which workaround doesn't seems nice (I got it). The problem is custom url resolver result always treat as non-MVC url (see): node.UsesDefaultUrlResolver() returns false, but I need true, because the node doesn't have url, it is a original SiteMapNode which has passed through specific filter.
Any thoughts? Thanks!
The text was updated successfully, but these errors were encountered: