Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6155685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:28:40+00:00 2026-05-23T20:28:40+00:00

Our web application is going to be deployed as part of a system with

  • 0

Our web application is going to be deployed as part of a system with SSO. After session timeout, my XmlHttpRequests get redirected to a login page, we have no control over this.

On each AJAX response handler I must check whether the response text is a full HTML page or not. (HTML fragments and JSON are valid responses.)

I must admit I’m quite new to client side technologies. I catch full HTML pages like so:

if (data.search(/<html>/) > -1) { ... }

I assume this is horribly inefficient, relies on our conventions, and may introduce subtle bugs in the future.
Especially considering there’s a whole web browser there whose main purpose is parsing HTML…

Please share more elegant solutions for recognizing text as complete HTML documents!

(JQuery is already in use in the project.)

Closing edit:

I’m in a bit of a pickle in selecting one answer to accept, as the solution seems to be a composite of the two plus ideas from the comments:

I’ll have separate validators for JSON and HTML fragment:

  • Where I’m expecting JSON, the response must be JSON.

  • Where I’m expecting an HTML fragment (and not a complete document) the response must end in a closing tag (disregarding whitespace), but not (case insensitive). The SSO login page will have to end in , we’ll document this “limitation”.

Thanks everyone for contributing!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:28:41+00:00Added an answer on May 23, 2026 at 8:28 pm

    If you want to check whether the response is a full HTML page you probably want to start looking at the end, don’t you? Checking whether </html> is at the end doesn’t waste much performance. If you don’t want that, please clarify what you mean by full HTML page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our web application sends e-mails. We have lots of users, and we get lots
We keep getting this error randomly in our web application. System.Data.SqlClient.SqlException: A network-related or
Part of my project wrote all their code in C#. Our web application is
I am going to deploy our Web Application under Production server. Is including printStackTrace
Our web application renders fast in some IE browsers, slow in others... It seems
On our web application, the search results are displayed in sortable tables. The user
In our web application we have a directory which resides outside of the project.
For our web application, we are sending the X-UA-Compatible -> IE=EmulateIE7 for all the
On our web application I am trying to ping a 3rd party site to
we need reports in our web application and there is the free ReportViewer Control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.