Skip to content

Pagination Links not forming correctly after hosting on IIS #948

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

Closed
Priyankadhavale opened this issue Feb 12, 2021 · 6 comments
Closed

Pagination Links not forming correctly after hosting on IIS #948

Priyankadhavale opened this issue Feb 12, 2021 · 6 comments

Comments

@Priyankadhavale
Copy link

Priyankadhavale commented Feb 12, 2021

DESCRIPTION

After hosting the JANDC used application on IIS, the pagination links generated by JANDC does not contain the application name in URL

STEPS TO REPRODUCE

I have tried adding the my application under Default site

so my URL forms like
https://[ip address]/api/v1/articles?page[size]=10&page[number]=2

So whenever I am accessing this URL => I am not able to get the result

Actual URL

https://[ip address]/[applicationName]/api/v1/articles?page[size]=10&page[number]=2

EXPECTED BEHAVIOR

Can you please let me know if we can achieve this with JANDC and how we can achieve this.

ACTUAL BEHAVIOR

Right now the base path that means https://: this much only added to pagination links in Links section of result.

VERSIONS USED

  • JsonApiDotNetCore version: 4.0.0-beta1
  • ASP.NET Core version:3.1
  • Entity Framework Core version:3.1.10
  • Database provider:SQL server
@bart-degreed
Copy link
Contributor

Hi @Priyankadhavale, thanks for reporting this.

Its been many years ago since I last used IIS and its not something I can easily repro/debug. However, I can give you some pointers where to put breakpoints so you can analyze this yourself.

The IJsonApiRequest.BasePath is set here:

request.BasePath = GetBasePath(primaryResourceContext.PublicName, options, httpRequest);

Which is then used to render paging/self links here:

Maybe some of the suggestions here help in finding a way to obtain the IIS application name.

Hope that helps!

@Priyankadhavale
Copy link
Author

Hi @bart-degreed ,

Thanks for quick response.

I have seen the code and in GetBasePath() method the following code is not adding httpRequest.PathBase (gives application name on iis ) string to builder because of that I can only see the URL till "http://[ip-address]"
if (!options.UseRelativeLinks)
{
builder.Append(httpRequest.Scheme);
builder.Append("://");
builder.Append(httpRequest.Host);
}

Can you please suggest on this

Thanks,
Priyanka

@bart-degreed
Copy link
Contributor

I think you're on the right track with PathBase (explanation here).

Things that come to mind:

  • how can we write an integration test for this?
  • how does this affect the GetCustomRoute method? (used for [Route("some/path/to/articles")] on controllers)

Looks like I'll need to setup IIS after all, to try these things out. At the moment, other work has higher priority. Is this something you need soon or can it wait some time?

In the mean time, can you work around this by hosting at the IIS root instead of from an application virtual directory?

@Priyankadhavale
Copy link
Author

Hi @bart-degreed ,

We are using JANDC package in our application and we have release in next month. Is it possible that we can get fix for this till mid of March 2021.

And in the mean time we are trying to use this by hosting on IIS root instead of application virtual directory. There the URL is forming correctly.

Thanks,
Priyanka

@bart-degreed
Copy link
Contributor

I cannot make hard promises but I intend to help you. Does #953 fix the problem?

@bart-degreed
Copy link
Contributor

Fixed in v4.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants