1

I've got an Asp.net MVC action that creates user account(after input validation). And a View containing registration form that invokes this action. While action validates input, user is left with webbrowser waiting for server response and click submit button a few more times. This creates several accounts. Is there a way to prvent user from form resubmition without javascript. I cannot use javascript in this project it is intended for non javascript browsers. Or can you suggest(server) other solution?

EDIT:

  1. This form request use POST method
  2. JavaScript is not allowed because this Web Application is aimed for special web browsers for people with disabilities that do not support javascript
6
  • 2
    Web Application without using JS... sound strange ... and that too in MVC. Commented Mar 26, 2015 at 12:21
  • 1
    Is it a Get or Post Request? Either way you can apply check that if the user already exists then redirct him. Commented Mar 26, 2015 at 12:23
  • @Rajeev Kumar there are special web browsers for people with disabilities that do not support javascript. This Web Application is aimed for them. Commented Mar 26, 2015 at 12:30
  • Will that browser render page if it is not completed? If yes, you can redirect user to new page with validation code. It will output some initial HTML with text like "Doing some work... please wait". And when validation is done - output the rest of page: "Work is done. Click here to log in". Commented Mar 26, 2015 at 12:38
  • 1
    I'm curious: why isn't JavaScript allowed in browsers used by people with disabilities? Commented Mar 26, 2015 at 12:41

3 Answers 3

1

You have to handle the situation on the server-side then, there's no way around that.

There are 3 options that come to my mind atm:

  • create a cookie and for each submit check if it exists
  • similar, but using a session object
  • before creating a new account, always check if the user exists in the database. THIS should be a no-brainer anyway!
Sign up to request clarification or add additional context in comments.

Comments

0

You can add a unique hidden token as part of the form. This token can also be saved as part of the session on the server.

When the user posts the form on the first action, the token is validated and a flag set to indicate the request is being processed. The action processed and results presented. If, while awaiting results, the user attempts to repost the request, the token validation fails as the request is still being processed.

On a side node, the main reason people continuously click is that there is no feed back on whether the request was received by the server or not. To this affect, it might be better to redirect the user to an interim page that shows the request is being processed. Which in conjunction with the above can be used to show the request progress and redirect to the appropriate page when completed.

Of-course, you should also consider making the process a bit lighter. So, that the system can respond quickly to input rather than making the user wait.

Comments

0

Is it a requirement to use MVC? I think you can accomplish something similar using WebForms. When the user submit the request, in the code behind you can disabled the submit button like this:

btnSubmit.Enabled = false;

But if MVC is a must be, @walther answer would be correct

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.