Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Approach on getting rid of server side validation

Approach on getting rid of server side validation

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesignsysadminhelp
10 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fabio Franco
    wrote on last edited by
    #1

    Hi all, first of all thanks for taking the time to look into this. My scenario is the following: ASP.NET 4 Web Forms app distributed in 4 layers (C# projects): 1 - UI (Web Forms) 2 - DomainModel (Behavior and Data. This layer has no knowledge of the other layers) 3 - DAL (Get data from the database to fill the domain model) 4 - Service (This layer is responsible for managing calls from Web Forms, fetching the data from the database and filling the model) So what happens is, once the user loads a certain user interface, there is a particular area where the user interface constantly changes depending on the user input. And all the rules for those are on the domain model. So for example: User types XYZ on field 1: Fields 2 and 3 show up because user typed XYZ on field 1. If user types ABC on field 1: Then Fields 4 and 5 show up because user typed ABC on field 1. Internally, when the user changes the value of a text box or dropdownlist, the codebehind updates the model with that value and the model returns the new fields that need to be set. This works quite well, with update panels and the roundtrips to the server. The problem starts when the user is in a far away location. Example: Server US, User Spain. It takes a long time for the user to have its data refreshed on the update panel so he can't be effective on filling the fields, they usually are a lot of fields so we are having a productivity bottle neck with this. A way to solve this issue is to bring the rules to client side as javascript, but I'm running away from it for several reasons: 1 - I'd need to replicate the business rules on javascript. This means that I will loose lots of the C# OO features and this is can get really risky, since the rules can get complex. 2 - This would create a sync problem. If update one model, the other would need to be updated as well, this is a high risk of someday falling out of sync, if they ever get in perfect sync at all. 3 - I don't like the idea of having client side code containing too much information about the underlying business rules. Now, without touching the hardware infrastructure, do you have any suggestion on the approach on how mitigate this problem? Obviously distance is the main problem here and I can't bring the user closer to the server and vice-versa. If the scenario is unclear, please let me know what else I can explain. I appreciate any suggestion on this matter. Regards

    J V 2 Replies Last reply
    0
    • F Fabio Franco

      Hi all, first of all thanks for taking the time to look into this. My scenario is the following: ASP.NET 4 Web Forms app distributed in 4 layers (C# projects): 1 - UI (Web Forms) 2 - DomainModel (Behavior and Data. This layer has no knowledge of the other layers) 3 - DAL (Get data from the database to fill the domain model) 4 - Service (This layer is responsible for managing calls from Web Forms, fetching the data from the database and filling the model) So what happens is, once the user loads a certain user interface, there is a particular area where the user interface constantly changes depending on the user input. And all the rules for those are on the domain model. So for example: User types XYZ on field 1: Fields 2 and 3 show up because user typed XYZ on field 1. If user types ABC on field 1: Then Fields 4 and 5 show up because user typed ABC on field 1. Internally, when the user changes the value of a text box or dropdownlist, the codebehind updates the model with that value and the model returns the new fields that need to be set. This works quite well, with update panels and the roundtrips to the server. The problem starts when the user is in a far away location. Example: Server US, User Spain. It takes a long time for the user to have its data refreshed on the update panel so he can't be effective on filling the fields, they usually are a lot of fields so we are having a productivity bottle neck with this. A way to solve this issue is to bring the rules to client side as javascript, but I'm running away from it for several reasons: 1 - I'd need to replicate the business rules on javascript. This means that I will loose lots of the C# OO features and this is can get really risky, since the rules can get complex. 2 - This would create a sync problem. If update one model, the other would need to be updated as well, this is a high risk of someday falling out of sync, if they ever get in perfect sync at all. 3 - I don't like the idea of having client side code containing too much information about the underlying business rules. Now, without touching the hardware infrastructure, do you have any suggestion on the approach on how mitigate this problem? Obviously distance is the main problem here and I can't bring the user closer to the server and vice-versa. If the scenario is unclear, please let me know what else I can explain. I appreciate any suggestion on this matter. Regards

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      You write javascript to validate on the client side, and leave the server side validation intact. If the javascript is written well, then the server side validation will always pass on the first postback, changing the users perception that the site is sound. There's nothing wrong with 2 sets of validation.

      F 1 Reply Last reply
      0
      • J jkirkerx

        You write javascript to validate on the client side, and leave the server side validation intact. If the javascript is written well, then the server side validation will always pass on the first postback, changing the users perception that the site is sound. There's nothing wrong with 2 sets of validation.

        F Offline
        F Offline
        Fabio Franco
        wrote on last edited by
        #3

        The thing is that is not validation only. There is behavior. New controls are created on the fly based on the users decision to input other fields. All of these are based on complex business rules implemented with the help of full blown object orientation design. Edit: Sorry, forgot thank you for your input.

        To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

        J 1 Reply Last reply
        0
        • F Fabio Franco

          The thing is that is not validation only. There is behavior. New controls are created on the fly based on the users decision to input other fields. All of these are based on complex business rules implemented with the help of full blown object orientation design. Edit: Sorry, forgot thank you for your input.

          To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          You can do wildcards with jquery, or bind certain control types to validate functions, and javascript does support regex. As far as dynamic controls goes, you make dynamic javascript.

          F 1 Reply Last reply
          0
          • J jkirkerx

            You can do wildcards with jquery, or bind certain control types to validate functions, and javascript does support regex. As far as dynamic controls goes, you make dynamic javascript.

            F Offline
            F Offline
            Fabio Franco
            wrote on last edited by
            #5

            Thanks again for your input, I'll certainly consider it, but I don't think I can replicate the business rules with regex and jscript without making a big mess and having a high risk of not reflecting the real underlying business model. If I try to do it I may endup have an entire business model based on javascript. And that's what I am trying to avoid. Thanks again for your input.

            To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

            J 1 Reply Last reply
            0
            • F Fabio Franco

              Thanks again for your input, I'll certainly consider it, but I don't think I can replicate the business rules with regex and jscript without making a big mess and having a high risk of not reflecting the real underlying business model. If I try to do it I may endup have an entire business model based on javascript. And that's what I am trying to avoid. Thanks again for your input.

              To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #6

              So you finally got bit by the Update Panel and Microsoft Validators. I dumped the use of them 3 years ago, and now I plan everything without them. I learned that lesson the hard way, and had to rewrite everything with a whole new way of thinking. I had a problem with the update panel being sort of jittery, and the user was never sure if the click went through. The progress indicator took too long on the round trip from the server, and needed to be instant. All you can do is keep the code and use Akamai Edge Technology, or shift it all to JQuery, or a mixture of both. As long as the user sees something happening right away, they will wait. They just need a signal. Basically you need to smooth out your gig, so it's silkly smooth looking, while the background transmissions can be erratic.

              F 1 Reply Last reply
              0
              • J jkirkerx

                So you finally got bit by the Update Panel and Microsoft Validators. I dumped the use of them 3 years ago, and now I plan everything without them. I learned that lesson the hard way, and had to rewrite everything with a whole new way of thinking. I had a problem with the update panel being sort of jittery, and the user was never sure if the click went through. The progress indicator took too long on the round trip from the server, and needed to be instant. All you can do is keep the code and use Akamai Edge Technology, or shift it all to JQuery, or a mixture of both. As long as the user sees something happening right away, they will wait. They just need a signal. Basically you need to smooth out your gig, so it's silkly smooth looking, while the background transmissions can be erratic.

                F Offline
                F Offline
                Fabio Franco
                wrote on last edited by
                #7

                jkirkerx wrote:

                So you finally got bit by the Update Panel

                Definitelly...

                jkirkerx wrote:

                I learned that lesson the hard way

                I'm thinking that might be my case as well, couz I don't have time to rewrite everything. I'm trying to think of a solution that does not cost me a lot of time and improve the performance.

                jkirkerx wrote:

                As long as the user sees something happening right away, they will wait.

                They can't wait in banking business. If it takes too long, it won't work, because you know, time is money. Imagine having to fill 30+ fields and having to wait 2 to 4 seconds for everyone of them. The processing indicator doesn't help with that :( I wish I could touch the infrastructure to work it out, but I can't. Well, I'll keep thinking and maybe there will be a solution sometime. To me, the best thing is if the code behind could be cached locally (can it?) to avoid the roundtrips, that would solve my problems. Anyway, thanks for the suggestions, wish me luck :)

                To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                J 1 Reply Last reply
                0
                • F Fabio Franco

                  jkirkerx wrote:

                  So you finally got bit by the Update Panel

                  Definitelly...

                  jkirkerx wrote:

                  I learned that lesson the hard way

                  I'm thinking that might be my case as well, couz I don't have time to rewrite everything. I'm trying to think of a solution that does not cost me a lot of time and improve the performance.

                  jkirkerx wrote:

                  As long as the user sees something happening right away, they will wait.

                  They can't wait in banking business. If it takes too long, it won't work, because you know, time is money. Imagine having to fill 30+ fields and having to wait 2 to 4 seconds for everyone of them. The processing indicator doesn't help with that :( I wish I could touch the infrastructure to work it out, but I can't. Well, I'll keep thinking and maybe there will be a solution sometime. To me, the best thing is if the code behind could be cached locally (can it?) to avoid the roundtrips, that would solve my problems. Anyway, thanks for the suggestions, wish me luck :)

                  To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  No it can't be cached locally, because only the server can process asp.net code, the browser only supports script like Javascript and Jquery. There are some other scripts that can be ran, but it's still script. I use Jquery now, and web services to replace the update panel. I've worked with Google Maps, AdSense, You Tube, and noticed that they use tons of Javascript with web services. Check out a You Tube interface, when your on the movie, above the movie is a javascript / json web service that populates the posters movie collection. It's true data on demand, so the initial page load is only visible data, but you can open a container, and that container will populate on demand, providing more data only if needed. [ Concept ] You could build a base structure or framework container with asp.net, and populate or paint that container with Javascript that produces new html objects dynamically, validate with a new set of javascript, and then send the anwsers back using a web service. With Javascript, you can wipe the container clean, get a new set of controls via web service, and repeat the process. Just keep the information on tap for the future, the next time you write a web based app, you may want to consider doing it the Google way. I think that half of the Microsoft controls were developed in house as a quick way to provide more features, but were never really tested in a production environment, in which they are too slow, or just unstable.

                  F 1 Reply Last reply
                  0
                  • J jkirkerx

                    No it can't be cached locally, because only the server can process asp.net code, the browser only supports script like Javascript and Jquery. There are some other scripts that can be ran, but it's still script. I use Jquery now, and web services to replace the update panel. I've worked with Google Maps, AdSense, You Tube, and noticed that they use tons of Javascript with web services. Check out a You Tube interface, when your on the movie, above the movie is a javascript / json web service that populates the posters movie collection. It's true data on demand, so the initial page load is only visible data, but you can open a container, and that container will populate on demand, providing more data only if needed. [ Concept ] You could build a base structure or framework container with asp.net, and populate or paint that container with Javascript that produces new html objects dynamically, validate with a new set of javascript, and then send the anwsers back using a web service. With Javascript, you can wipe the container clean, get a new set of controls via web service, and repeat the process. Just keep the information on tap for the future, the next time you write a web based app, you may want to consider doing it the Google way. I think that half of the Microsoft controls were developed in house as a quick way to provide more features, but were never really tested in a production environment, in which they are too slow, or just unstable.

                    F Offline
                    F Offline
                    Fabio Franco
                    wrote on last edited by
                    #9

                    jkirkerx wrote:

                    No it can't be cached locally, because only the server can process asp.net code, the browser only supports script like Javascript and Jquery. There are some other scripts that can be ran, but it's still script.

                    Of this I'm aware, I was thinking more like a a local web server, like a plugin or something...

                    jkirkerx wrote:

                    Just keep the information on tap for the future, the next time you write a web based app, you may want to consider doing it the Google way.

                    I'll certainly consider it.

                    To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                    1 Reply Last reply
                    0
                    • F Fabio Franco

                      Hi all, first of all thanks for taking the time to look into this. My scenario is the following: ASP.NET 4 Web Forms app distributed in 4 layers (C# projects): 1 - UI (Web Forms) 2 - DomainModel (Behavior and Data. This layer has no knowledge of the other layers) 3 - DAL (Get data from the database to fill the domain model) 4 - Service (This layer is responsible for managing calls from Web Forms, fetching the data from the database and filling the model) So what happens is, once the user loads a certain user interface, there is a particular area where the user interface constantly changes depending on the user input. And all the rules for those are on the domain model. So for example: User types XYZ on field 1: Fields 2 and 3 show up because user typed XYZ on field 1. If user types ABC on field 1: Then Fields 4 and 5 show up because user typed ABC on field 1. Internally, when the user changes the value of a text box or dropdownlist, the codebehind updates the model with that value and the model returns the new fields that need to be set. This works quite well, with update panels and the roundtrips to the server. The problem starts when the user is in a far away location. Example: Server US, User Spain. It takes a long time for the user to have its data refreshed on the update panel so he can't be effective on filling the fields, they usually are a lot of fields so we are having a productivity bottle neck with this. A way to solve this issue is to bring the rules to client side as javascript, but I'm running away from it for several reasons: 1 - I'd need to replicate the business rules on javascript. This means that I will loose lots of the C# OO features and this is can get really risky, since the rules can get complex. 2 - This would create a sync problem. If update one model, the other would need to be updated as well, this is a high risk of someday falling out of sync, if they ever get in perfect sync at all. 3 - I don't like the idea of having client side code containing too much information about the underlying business rules. Now, without touching the hardware infrastructure, do you have any suggestion on the approach on how mitigate this problem? Obviously distance is the main problem here and I can't bring the user closer to the server and vice-versa. If the scenario is unclear, please let me know what else I can explain. I appreciate any suggestion on this matter. Regards

                      V Offline
                      V Offline
                      vvashishta
                      wrote on last edited by
                      #10

                      Use Javascript Validation on controls, that works on client side only.

                      - Happy Coding - Vishal Vashishta

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups