Hello. I posted this on a MSSQL forum, went through it a bit, then they told me (2019 is so funny) they don't know anything about asp.net.
Can someone please help me here? Thanks.
Bottom line... After moving my MSSQL server away from the same machine as my IIS server (they're on two machines now, in different parts of the country, connecting over the public internet). .... Sometimes (I'm guessing at high latency times of the day like
early morning when I see it)........... If I post to my site.... IT POSTS Twice which gets annoying (posting meaning to execute an SP twice, that's all it's doing). I click once, it hits the SP twice. No code changes since I moved it. And it worked fine on
the same server for over a year.
Hello. I posted this on a MSSQL forum, went through it a bit, then they told me (2019 is so funny) they don't know anything about asp.net.
Can someone please help me here? Thanks.
Bottom line... After moving my MSSQL server away from the same machine as my IIS server (they're on two machines now, in different parts of the country, connecting over the public internet). .... Sometimes (I'm guessing at high latency times of the day like
early morning when I see it)........... If I post to my site.... IT POSTS Twice which gets annoying (posting meaning to execute an SP twice, that's all it's doing). I click once, it hits the SP twice. No code changes since I moved it. And it worked fine on
the same server for over a year.
Double inserts indicates an bug in the code. The things we see most often on the forum is a double tap on the submit button or the submit button invokes an AJAX POST as well as an HTML form submit. Sometimes we see double event wire ups which generally
happens in VB.NET Web Forms.
If you share your code, that causes this issue, we can take a look and fix you up. Otherwise, the browser's dev tools (F12) has a network trace that will show if the browser is sending two POST requests. That should get you started down the troubleshooting
path.
I don't understand how it could be "double post," by any native way.
1.) I have the submit using a javascript "confirm" button. Pressing, "OK" only submits it.
2.) This page worked perfectly fine for almost exactly one solid year when IIS and MSSQL were on the same box.
The only variable that changed was me moving them apart (geographically, aka: public internet).
Moreoever, I see this issue almost exclusively in the 8:30-10:30 ET hours which as we know is when traffic on the internet is very high, and latency among some providers is very low.
I don't understand how it could be "double post," by any native way.
1.) I have the submit using a javascript "confirm" button. Pressing, "OK" only submits it.
2.) This page worked perfectly fine for almost exactly one solid year when IIS and MSSQL were on the same box.
The only variable that changed was me moving them apart (geographically, aka: public internet).
Moreoever, I see this issue almost exclusively in the 8:30-10:30 ET hours which as we know is when traffic on the internet is very high, and latency among some providers is very low.
Any ideas?
I provided my ideas above; usually double POSTs is a bug. The browser is sending multiple requests, server side event handler firing twice or a misbehaving loop.
I've never experienced double INSERTs due to the Internet being busy. I'm not sure how a busy network would duplicate INSERTs. Setup a network trace between 8:30 and 10:30 and log the traffic.
I provided a trace in that example. It's almost as if the IIS server "can't quite see MSSQL and there is no failsafe" so it just "tries again,." Is it possible IIS natively is just buggy like that? The question is, is-that what it's doing?
Meaning: Should there be some ack back from MSSQL before IIS sends the SP? Is this something (some failsafe) we could add to the .net code? Meaning, some type of... "don't send the execute sp request if you sent it once until you hear back."
What I know is nothing changed, and it worked beautifully for over one year and at least 2,000 active postings (executing of the sp via the vb.net/asp.net code).
Does the SQL server need to be "linked" in some way? As of now I'm connecting via .dbml with the definitions in web.config.
It's almost as if the IIS server "can't quite see MSSQL and there is no failsafe" so it just "tries again,." Is it possible IIS natively is just buggy like that? The question is, is-that what it's doing?
Meaning: Should there be some ack back from MSSQL before IIS sends the SP? Is this something (some failsafe) we could add to the .net code? Meaning, some type of... "don't send the execute sp request if you sent it once until you hear back."
IIS handles HTTP requests. IIS does not open a connection to the DB, your code does.
jbassett
What I know is nothing changed, and it worked beautifully for over one year and at least 2,000 active postings (executing of the sp via the vb.net/asp.net code).
If I only had a dollar for every time I hear nothing changed.
jbassett
Does the SQL server need to be "linked" in some way? As of now I'm connecting via .dbml with the definitions in web.config.
I have no idea what you are asking. A dbml file is a UI interface that shows your LINQ to SQL Entities and related Entities. The actual connection is standard ADO.NET.
So you tried to see if you have two http requests? Sometimes it is the handler which is mistakenly binded twice to the same event (so you have one http request and the handler is called twice). Sometimes it is an ajax request on a submit button and this
event not being properly cancelled (so you really have two http requests).
You may ask why it worked before but it is basically irrelevant. See first why it doesn't work as expected now...
I'll keep looking. Nothing in the code changed, except the web.config pointer to the new server. I'll try some other traces. It is weird. But you don't think I need to "link it" in some way? Just .dbml (instead of the old way, calling it all in code) and
web.config?
Maybe I did need some code from the beginning (likely so as I stated from the beginning) but How did "moving the servers apart" (the only variable introduced) exacerbate this problem? It must have, and that is where to find the answer. So that point should
not only not be dismissed, it should be lauded.
I'll keep looking. Nothing in the code changed, except the web.config pointer to the new server. I'll try some other traces. It is weird. But you don't think I need to "link it" in some way? Just .dbml (instead of the old way, calling it all in code) and
web.config?
I'm not sure what you are asking. a .dbml file is designer file that provides a UI interface for code generation.
jbassett
Maybe I did need some code from the beginning (likely so as I stated from the beginning) but How did "moving the servers apart" (the only variable introduced) exacerbate this problem? It must have, and that is where to find the answer. So that point should
not only not be dismissed, it should be lauded.
Sure, separating the Web Application and Database server could expose the bug.
The first step in troubleshooting is reproducing the behavior. Once you can reproduce the
problem then you should be able to
isolate the code path.
We cannot reproduce your environment and therefore cannot troubleshoot this issue. We can only fall back on our experiences. I have never witnessed duplicate INSERTs due to Internet traffic or using a 2-tier design.
As it seems you have a SP that runs twice, you could check :
- is this really the case ? (if you INSERT based on other tables a wrong JOIN could maybe cause duplicated rows to be inserted)
- if ok, I would check if I have two http requests or if the handler is called twice for a single http request
Most often this kind of issue happens (it always happen or in rare cases ?) when a user is clicking twice or is refreshing the page causing another POST (depending on how your page is done).
In short don't stop at looking that you insert a row twice and then immediately wonder what could cause this . Instead look at what your code does exactly to cause this double insert. Then you should quickly find the root cause.
Member
28 Points
284 Posts
My site is posting twice.
Jun 27, 2019 11:27 AM|jbassett|LINK
Hello. I posted this on a MSSQL forum, went through it a bit, then they told me (2019 is so funny) they don't know anything about asp.net.
Can someone please help me here? Thanks.
Bottom line... After moving my MSSQL server away from the same machine as my IIS server (they're on two machines now, in different parts of the country, connecting over the public internet). .... Sometimes (I'm guessing at high latency times of the day like early morning when I see it)........... If I post to my site.... IT POSTS Twice which gets annoying (posting meaning to execute an SP twice, that's all it's doing). I click once, it hits the SP twice. No code changes since I moved it. And it worked fine on the same server for over a year.
Original thread: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dcbc9a7b-3a2d-4238-8113-9038e1742d1c/why-remote-mssql-server-posting-back-twice-but-local-is-not?forum=sqlnetfx
All-Star
52961 Points
23565 Posts
Re: My site is posting twice.
Jun 27, 2019 11:50 AM|mgebhard|LINK
Double inserts indicates an bug in the code. The things we see most often on the forum is a double tap on the submit button or the submit button invokes an AJAX POST as well as an HTML form submit. Sometimes we see double event wire ups which generally happens in VB.NET Web Forms.
If you share your code, that causes this issue, we can take a look and fix you up. Otherwise, the browser's dev tools (F12) has a network trace that will show if the browser is sending two POST requests. That should get you started down the troubleshooting path.
Member
28 Points
284 Posts
Re: My site is posting twice.
Jun 27, 2019 07:52 PM|jbassett|LINK
I don't understand how it could be "double post," by any native way.
1.) I have the submit using a javascript "confirm" button. Pressing, "OK" only submits it.
2.) This page worked perfectly fine for almost exactly one solid year when IIS and MSSQL were on the same box.
The only variable that changed was me moving them apart (geographically, aka: public internet).
Moreoever, I see this issue almost exclusively in the 8:30-10:30 ET hours which as we know is when traffic on the internet is very high, and latency among some providers is very low.
Any ideas?
All-Star
52961 Points
23565 Posts
Re: My site is posting twice.
Jun 27, 2019 08:31 PM|mgebhard|LINK
I provided my ideas above; usually double POSTs is a bug. The browser is sending multiple requests, server side event handler firing twice or a misbehaving loop.
I've never experienced double INSERTs due to the Internet being busy. I'm not sure how a busy network would duplicate INSERTs. Setup a network trace between 8:30 and 10:30 and log the traffic.
Member
28 Points
284 Posts
Re: My site is posting twice.
Jun 28, 2019 11:47 AM|jbassett|LINK
I provided a trace in that example. It's almost as if the IIS server "can't quite see MSSQL and there is no failsafe" so it just "tries again,." Is it possible IIS natively is just buggy like that? The question is, is-that what it's doing?
Meaning: Should there be some ack back from MSSQL before IIS sends the SP? Is this something (some failsafe) we could add to the .net code? Meaning, some type of... "don't send the execute sp request if you sent it once until you hear back."
What I know is nothing changed, and it worked beautifully for over one year and at least 2,000 active postings (executing of the sp via the vb.net/asp.net code).
Does the SQL server need to be "linked" in some way? As of now I'm connecting via .dbml with the definitions in web.config.
All-Star
52961 Points
23565 Posts
Re: My site is posting twice.
Jun 28, 2019 12:11 PM|mgebhard|LINK
No a network trace or SQL logging.
IIS handles HTTP requests. IIS does not open a connection to the DB, your code does.
If I only had a dollar for every time I hear nothing changed.
I have no idea what you are asking. A dbml file is a UI interface that shows your LINQ to SQL Entities and related Entities. The actual connection is standard ADO.NET.
All-Star
48490 Points
18068 Posts
Re: My site is posting twice.
Jun 28, 2019 12:11 PM|PatriceSc|LINK
Hi,
So you tried to see if you have two http requests? Sometimes it is the handler which is mistakenly binded twice to the same event (so you have one http request and the handler is called twice). Sometimes it is an ajax request on a submit button and this event not being properly cancelled (so you really have two http requests).
You may ask why it worked before but it is basically irrelevant. See first why it doesn't work as expected now...
Member
28 Points
284 Posts
Re: My site is posting twice.
Jun 28, 2019 04:37 PM|jbassett|LINK
I've been developing over 30 years. I don't have the answer but my questions are founded and legitimate.
Member
28 Points
284 Posts
Re: My site is posting twice.
Jun 28, 2019 04:39 PM|jbassett|LINK
I'll keep looking. Nothing in the code changed, except the web.config pointer to the new server. I'll try some other traces. It is weird. But you don't think I need to "link it" in some way? Just .dbml (instead of the old way, calling it all in code) and web.config?
Member
28 Points
284 Posts
Re: My site is posting twice.
Jun 28, 2019 04:43 PM|jbassett|LINK
Maybe I did need some code from the beginning (likely so as I stated from the beginning) but How did "moving the servers apart" (the only variable introduced) exacerbate this problem? It must have, and that is where to find the answer. So that point should not only not be dismissed, it should be lauded.
All-Star
52961 Points
23565 Posts
Re: My site is posting twice.
Jun 28, 2019 05:19 PM|mgebhard|LINK
I'm not sure what you are asking. a .dbml file is designer file that provides a UI interface for code generation.
Sure, separating the Web Application and Database server could expose the bug.
The first step in troubleshooting is reproducing the behavior. Once you can reproduce the problem then you should be able to isolate the code path.
We cannot reproduce your environment and therefore cannot troubleshoot this issue. We can only fall back on our experiences. I have never witnessed duplicate INSERTs due to Internet traffic or using a 2-tier design.
All-Star
48490 Points
18068 Posts
Re: My site is posting twice.
Jul 03, 2019 11:05 AM|PatriceSc|LINK
As it seems you have a SP that runs twice, you could check :
- is this really the case ? (if you INSERT based on other tables a wrong JOIN could maybe cause duplicated rows to be inserted)
- if ok, I would check if I have two http requests or if the handler is called twice for a single http request
Most often this kind of issue happens (it always happen or in rare cases ?) when a user is clicking twice or is refreshing the page causing another POST (depending on how your page is done).
In short don't stop at looking that you insert a row twice and then immediately wonder what could cause this . Instead look at what your code does exactly to cause this double insert. Then you should quickly find the root cause.