Skip to content
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

Can't visit IIS site with ASP core #773

Closed
olee opened this issue Oct 19, 2017 · 9 comments

Comments

3 participants
@olee
Copy link

commented Oct 19, 2017

  • Operating System: Windows
  • Cypress package version: 1.0.2
  • Cypress binary version: 1.0.2
  • Browser: Chrome

If I try to visit a page which is hosted through IIS (Express or on azure as app service) written by using ASP core, I get the following error when trying to access a page:

CypressError: cy.visit() failed trying to load:

https://XYZW.azurewebsites.net/about?testing=1

The content-type of the response we received from your web server was:

  > null

This was considered a failure because responses must have content-type: 'text/html'

However, you can likely use cy.request() instead of cy.visit().

cy.request() will automatically get and set cookies and enable you to parse responses.

Accessing the url directly without any path appended (eg. https://XYZW.azurewebsites.net/?testing=1 instead of https://XYZW.azurewebsites.net/about?testing=1) works without any problems.

This is nearly the same as #309

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Oct 19, 2017

I have been unable to successfully visit the website addresses you listed regularly in the browser. Are you sure you've written the url correctly? Maybe I'm not understanding something.

screen shot 2017-10-19 at 12 02 46 pm

@brian-mann

This comment has been minimized.

Copy link
Member

commented Oct 19, 2017

It's possibly Cypress is telling you the exact error message. That your server is sending null content-type headers and it requires it to be text/html...

Curl your server and see what it sends. Post a screenshot here if you cannot provide the external URL.

@olee

This comment has been minimized.

Copy link
Author

commented Oct 24, 2017

unbenannt

The thing is, if I open the shown url in a new tab in the same browser, it works perfectly fine.
Only through cypress visit it does not work.

Also important is that if I just visit / and not /about or any other path, it loads properly.

@olee

This comment has been minimized.

Copy link
Author

commented Nov 15, 2017

Anything new for this issue?

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Nov 16, 2017

Cypress often takes the route of being more opinionated than other testing tools. Part of what we're trying to do is catch errors in your application that you may not find otherwise. We do not take a strategy of guessing the MIME type as some browsers do. There are many reasons for this that you can read here: https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Configuring_server_MIME_types

That being said, we'd like to confirm that this is not an error on our part, but to do that you will need to confirm that the Content-Type is set from your server and is not in fact, null.

@olee

This comment has been minimized.

Copy link
Author

commented Nov 17, 2017

It seems the content type is actually null.
Even then, there should be some kind of setting, to allow that kind of behaviour.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Nov 17, 2017

We're not going to update the behavior to accommodate for null MIME types. This would mean we would have to guess the MIME type which we're not going to do for a couple of reasons:

  1. Guessing the content-type no longer gives the server the control to decide what content-type the server wants.
  2. Guessing the content-type opens Cypress itself up to potential security vulnerabilities.

We suggest you do not send a null MIME type from your server as, according to the HTTP specification, browsers have no way of knowing how you intend for them to display and process your content.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

We've changed our implementation some regarding this issue. If the content-type is null or undefined, we now look at the content that was visited and evaluate whether it looks like HTML, if it is - we do not error and continue as if it is content-type: text/html.

If it does not look like HTML, then it will still error as shown above in this issue.

The code for this is done in #4321, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@cypress-bot

This comment has been minimized.

Copy link

commented Jun 27, 2019

Released in 3.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.