Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3874416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:57+00:00 2026-05-19T22:08:57+00:00

I’m coming from a WebForms world where all logic is located in the codebehind

  • 0

I’m coming from a WebForms world where all logic is located in the codebehind of the aspx-pages. After reading a few books on ASP.NET MVC, listening to some podcast and watching some videos on Tekpub, I’ve decided that it is time to approach things a bit differently.

Unfortunately, I’m already stuck.

I’m trying to build some sort of small and basic CMS in which I can add multiple websites.

I know I should keep my controllers thin, so I guess I should use some sort of service class (let’s call it WebsiteService) to do this. I’m using Entity Framework for data access and my Views all use specific ViewModels. When I Create or Edit a Website, these four things should happen:

  • Validate the input
  • Add information about the Website to the database (Update information if it’s an Edit)
  • Create a directory on disk (Possibly rename the directory if it’s an Edit)
  • Add a host header to an IIS Website (Possible remove the old host header and a new one if it’s an Edit)

Basically, I guess the WebsiteService should perform more advanced validation, write to the database, create/edit a directory, add/remove host headers and return something to the controller to indicate if it succeeded or not.

What should this class look like? I have a few questions to which I don’t know the answer.

  1. Should the WebsiteService also translate the CreateWebsite ViewModel to the actual Website class or should something else do this so that the WebsiteService accepts an actual Website object?
  2. Basic input validation is done by using Validation attributes on the ViewModel. More extensive validation (“Is there already a Website with this domain name in the database?”) should also be done. Should the WebsiteService do this as well?
  3. Should all 3 steps (save to database, create directory, add host header to IIS) be done in one public method (WebsiteService.SaveWebsite(ViewModels.CreateWebsite website)) or should I provide separate methods which the controller has to call? (I guess not because I suppose the call order is important.)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:08:57+00:00Added an answer on May 19, 2026 at 10:08 pm

    The answers to this is partially subjective, matter of opinion, but here are my thoughts:

    1. It could. But a better approach would be to use AutoMapper to do this for you. One of the “must have” open source tools for data-driven MVC applications.

    2. Yes – input validation should be done via validation attributes on the View Models. More extensive/domain/business validation can either be done in the service, or on the domain models themselves. I prefer (and use) the second option. My domain models are also my POCO’s (used by EF), but i have extra methods/properties specific to the domain (but not the database).

    3. No, i think this should be in seperate methods, mainly for testability/seperation of concerns. You’ve got three things going on – database persistence, file writing and IIS work. That to me should be three different services. I would have your “WebsiteService” delegate these tasks to other services.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text I am displaying in SIlverlight that is coming from a CMS
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.