Note that there are some explanatory texts on larger screens.

plurals
  1. POPage 404'ing when running a SQL statement then redirecting
    primarykey
    data
    text
    <p>I'm having a very strange error, I'm by no means great with ASP.NET, but I'm helping develop a single sign-on application and I'm having trouble redirecting the user. I'm going to keep it as simple as possible, this is how it works:</p> <p>1.) They come from another website, it passes a Single Sign-On object with their ID in it</p> <p>2.) On page load, we use that ID to look up in our database and grab their information and if they're missing information, they have to fill it out.</p> <p>3.) If they're missing no information, it inserts their ID to an active session table, and then it redirects them to the final website</p> <p>The trouble is, I can do the SQL insert statement just fine when the page loads and it receives the data from the Single Sign-On object just fine; but when I run the SQL insert statement and then redirect them to another page the page just 404s. When the redirect is placed in there, we also get a Single Sign-On error, just saying that it couldn't complete. We register that the SQL statement ran, but they're not redirected; like said, it just 404s. </p> <p>Any reason why this would happen? Here is the general flow in code:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { SSOObject x = ServiceProvider.RecieveSSO(Request); userID = x.ID; SqlConnection conn = new SqlConnection(connString); conn.Open(); SqlCommand comm = ("INSERT INTO etc..."); comm.Parameters.AddWithValue("@ID", userID); comm.ExecuteNonQuery(); conn.Close(); comm.Dispose(); // It works fine up to here, but if I add this it 404's: Response.Redirect("http://ourwebsite.com/user/etc..."); } </code></pre> <p>Thanks in advance to anyone who gives this a go, it's been baffling me for a bit.</p> <p>Edit: Left out an important piece of information. If I comment out the SSO code and just hardcore the ID, the entire process works! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYou are explicitly passing a URL to the redirect method, in your actual code are you using the userID variable or something? Ex. are you using something like Response.Redirect("/user/" & userID); ? Can you post the URL from the browser? Ex. is the browser trying to navigate to http://ourwebsite.com/http://ourwebsite.com/user/etc... ?
      singulars
    2. COMy guess is that the redirect and SSO don't work well together. We get their ID from the SSO object, and then I generate a random string and insert their userID and the random string to a table (used as a session ID), so when they're redirected we're just looking for the random string so we know what ID it's associated with. So the url would be http://site.us.com/user/something=DEFAULT&session=" + randomString;
      singulars
    3. COBased off your comment, you should pretty easily be able to trouble shoot this. If you are hardcoding and it works but then you use a variable and it doesn't then there are two things I would do to find the issue - A: Set a breakpoint on your variable randomString and make sure it has a value B: Make sure you cast it as a string if it is not. Without seeing your exact code it is difficult to help troubleshoot (for instance, the code you have posted works just fine)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload