-
Notifications
You must be signed in to change notification settings - Fork 920
Added support for relative paths (non-root webapplications) #1141
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
Conversation
Hmm, did running Should be able to look at this soon, thanks for the PR. |
Undid all my changes, ran dev-build.bat and added my changes again. |
Thanks for much for sending the PR, I really appreciate you taking the time
to do so.
I did a bit of digging and the library doesn't really support IIS virtual
applications, although arguably it should, since that is a reasonably
common use case for enterprise systems. This PR is a pretty low level way
to accomplish that by opting out of UrlHelper, I would prefer to have that
set in ReactConfiguration instead and have the URL paths be written
relative to the application root. I'm guessing the current root can't be
detected automatically so we may need to make that explicit via the
configuration.
So as-is I don't want to merge this yet unless we have a more
fully-featured story for how IIS virtual applications work :)
In theory, if an option was added to `ReactConfiguration` that looked
something like `public string ScriptRoot {get; set;}`, where ScriptRoot is
either `https://example.com/some-virtual-app-name` or
`/some-virtual-app-name`, then asset URLs could be written using that as a
base.
…On Sun, Aug 2, 2020 at 10:57 PM, aldrashan ***@***.***> wrote:
Undid all my changes, ran dev-build.bat and added my changes again.
Works for netstandard2.0, netcoreapp3.0 and React.Web.Mvc4 now.
Test and checks have passed also now.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1141 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHGCFQKIMT2VE4M23FTWV3R6ZGVHANCNFSM4PCPIXDA>
.
|
Ok, but how can I have access to this alternative solution shown above, since it's not available as an official version in NuGet? I really don't want all the trouble of having to download the project and compile it for myself... could you please send me a compiled version of React.AspNet.dll containing these changes? |
Each PR gets its own build from github actions which has a nuget package
produced. You should be able to download the package and install it locally
in your project :)
Example:
https://github.com/reactjs/React.NET/actions/runs/211066835
On Mon, Aug 17, 2020 at 4:33 PM, arrudamarcos78 <notifications@github.com>
wrote:
… Thanks for much for sending the PR, I really appreciate you taking the
time to do so. I did a bit of digging and the library doesn't really
support IIS virtual applications, although arguably it should, since that
is a reasonably common use case for enterprise systems. This PR is a pretty
low level way to accomplish that by opting out of UrlHelper, I would prefer
to have that set in ReactConfiguration instead and have the URL paths be
written relative to the application root. I'm guessing the current root
can't be detected automatically so we may need to make that explicit via
the configuration. So as-is I don't want to merge this yet unless we have a
more fully-featured story for how IIS virtual applications work :) In
theory, if an option was added to ReactConfiguration that looked
something like public string ScriptRoot {get; set;}, where ScriptRoot is
either [https://example.com/some-virtual-app-name](
https://example.com/some-virtual-app-name%60) or /some-virtual-app-name,
then asset URLs could be written using that as a base.
… <#m_8234800419539356098_>
On Sun, Aug 2, 2020 at 10:57 PM, aldrashan *@*.***> wrote: Undid all my
changes, ran dev-build.bat and added my changes again. Works for
netstandard2.0, netcoreapp3.0 and React.Web.Mvc4 now. Test and checks have
passed also now. — You are receiving this because you commented. Reply to
this email directly, view it on GitHub <#1141 (comment)
<#1141 (comment)>>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHGCFQKIMT2VE4M23FTWV3R6ZGVHANCNFSM4PCPIXDA
.
Ok, but how can I have access to this alternative solution shown above,
since it's not available as an official version in NuGet? I really don't
want all the trouble of having to download the project and compile it for
myself... could you please send me a compiled version of React.AspNet.dll
containing these changes?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1141 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHGCFQSGSRENMXQDSSLHRDSBG44PANCNFSM4PCPIXDA>
.
|
If you don't mind me asking, what's the reason you don't want to use an (I)UrlHelper instance to generate the paths? The code looks like this:
I can push that version if you want to take a look at it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After considering this for a while I’ve come around to merging it as is. If we change the API in the future we can always provide a deprecation notice in advance.
Couldn't compile with all the <Compile Include="..\SharedAssemblyVersionInfo.cs" /> lines, since those files were missing, so had to remove those to test.
Relevant changes are in the src/React.AspNet/HtmlHelperExtensions.cs file.
In short: the best solution to implement these changes would be to have access to an IUrlHelper instance.
Since we call @Html.ReactGetScriptPaths() inside a view, we can change this to @Html.ReactGetScriptPaths(Url).
This way we can have access to the IUrlHelper.Content(...) method and we can use a relative path inside our webpack.config:
The generated asset-manifest.json file then looks like this:
This then gets correctly translated when your website isn't hosted as root (e.g. as a subapplication inside iis).
Successfully tested on a core 3.1 webapplication.