开发者

asp.net mvc 2 model not from db

开发者 https://www.devze.com 2023-02-14 22:58 出处:网络
in my asp.net mvc 2 web application i cant use a database to store data users post on the website. Instead the data needs to be captured in an XML file. The qu开发者_如何转开发estion is if i cant use

in my asp.net mvc 2 web application i cant use a database to store data users post on the website. Instead the data needs to be captured in an XML file. The qu开发者_如何转开发estion is if i cant use a database where do i base my pagemodel on in order to do model binding? I was thinking of a typed dataset maybe? what are alternatives to bind to?


I would make a strongly typed model for your pages, and then translate this into your Domain-model in the controllers (Check out AutoMapper to make this a bit more automatic).

Then I'd have XML-serialization take care of saving and loading the model down to the XML-file.

Typed Datasets would also work, but I'm just not a big fan of them to be honest :)

You can bind your pages to whatever datasource you wish - it's all about how you handle your formdata in your controllers.

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消