Comments (4)
Currently there is no way of doing this if you need all the routing behavior to go with it. Since you have your own logic of url generation, you can just write your own implementations of IUrlHelperFactory
and IUrlHelper
and add it to services. You will get no routing magic there. You'll need to put your logic in the Action
method, something like,
public class CustomUrlHelper : IUrlHelper
{
public string Action(UrlActionContext actionContext)
{
return $"{actionContext.Protocol}://{actionContext.Host}/{actionContext.Controller}/{actionContext.Action}";
}
.
.
.
}
And just add services.AddSingleton<IUrlHelperFactory, CustomUrlHelperFactory>();
in Program.cs
from entropy.
@Eilon Could you triage/assign?
from entropy.
@Bartmax, this is not a limitation. This is expected. This sample was added to demonstrate rendering a view to a string given a model. It does not involve any controllers or actions. This isn't meant for that. Both Url.Action() and AnchorTagHelper need actions and controllers to be present. So you can't use them here.
from entropy.
I understand, thanks for your explanation.
I'm using this to create email html from models. In the same project I do have controllers and actions, that's why I want to use something like <a asp-controller="Home" asp-action="Help">help</a>
but I also need them to be absolute not relative; //domain.com/Help
instead of /Help
.
Is there any sample that shows how to make it work with controller/actions or any guidance on what must be done/added ?
currently I'm doing logic on the ViewModel to get the url, maybe that's a reasonable way to do it ?
from entropy.
Related Issues (20)
- Flaky Test: ContainerFallbackWebTests.WindowsOS HOT 1
- Address package downgrade warnings HOT 1
- Localization Problem HOT 1
- Remove file "samples\Container.Fallback.Web\Documents - Shortcut.lnk"
- Fix Logging obsolete warnings HOT 2
- Warning: Dependency specified was Microsoft.AspNetCore.Diagnostics.Elm but ended up with Microsoft.AspNetCore.Diagnostics.Elm 0.1.0
- Investigate flaky AppVeyor and Travis builds HOT 1
- Extract common code in sample csproj to samples.props or common.props HOT 2
- Remove unnecessary file "samples/Owin.Nowin.HelloWorld/web.config" HOT 1
- Remove temporary workarounds HOT 1
- Travis: MSBuild fails in container-based environment HOT 1
- Update RenderViewToString to use `GetView` \ `FindView` fallback
- Mvc.CustomRazorPageHandlers sample update? HOT 4
- solution way to big, neverending loading HOT 1
- Unit test RazorViewToStringRenderer HOT 1
- Unable to render Razor to string. Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException
- RazorViewToStringRenderer partial views not working. HOT 1
- PagedList.cs How to upgrade to .net core 3.1?
- Mvc.RenderViewToString: support tag helpers
- About DataAnnotationLocalizerProvider to using EF
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entropy.