简体   繁体   中英

Asp.net vs Any web service?

I am soon to be building a website and I have never done such before. I have experience coding native application but not web applications.

I was thinking that my website (pretty simple site) will just use jquery to ask a web service for the data it needs. I was going to do the server side with ASP.Net but then I thought: "Why?"

Now I'm sure there is a reason to use Asp.Net but I could not think of one. My whole purpose is to show some data on the client side. Could I not just do this with jquery and Web Service Calls?

Keep in mind I have no experience with ASP.Net

Thanks

Yes, you could host plain HTML files on a server that make jQuery requests to web services using something like JSON or XML as your medium.

Though, using a bunch of spaghetti $.ajax(options) calls in your code could become cumbersome. I'm not heavy into front end development, so I try to limit the amount of those calls needed by my applications by using a heavier backend ASP.NET or ASP.NET MVC application. But, you could always get into the JavaScript prototype and create your own front-end library that handles your business/view objects.

Your services could be implemented as ASMX web services or using WCF. The latter could be self-hosted, hosted in a Windows Service (which it sounds like you may be familiar with already) or even in IIS. WCF gives you a lot more flexibility in defining endpoints. This just means you could write code once, and perhaps write lightweight filters to groom the data for the requesting endpoint. Eg a website might want the data in tabular format (JSON array of arrays) and some future service might just want data listed.

Of course, you're not limited to jQuery. There are many JavaScript libraries/frameworks out there that are fully equipped to handle the front end assuming you have an organized backend. To name a few, backbone.js, spine.js, KnockoutJS (for heavy front end apps)

Unless the reports are insanely simple and small (no paging required), you would still want a middle layer.

Personally, if you have access to asp.net mvc, I would go that route. I'm a fan of jQuery also, so I would still use that to render the grid:

http://www.trirand.com/blog/?page_id=5

I wouldn't use jQuery calls for everything in your application. There are some instances where postbacks are preferrable for performance, among other reasons. Doing everything on the client is not a good idea because it will add unecessary limitations. Sometimes, it's just plain easier to handle things server-side in the code behind. You just have to strike the right balance.

If your application is simple, I don't see any reason to incorporate web services, either. If you were building an enterprise-level application then it would be justified, but for something simple like what you've desribed it would be major overkill.

The rule of thumb is: design to your needs, and don't make your architecture more complicated than it needs to be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM