1

I work in a small environment that consists of me (the developer) and my colleague (the designer).

We have a good intersection of skills so mostly we work pretty well together, currently we host all javascript files, css files and images in an s3 bucket so he can adjust our front end stuff without me having to deploy the changes to the server.

The only part of our workflow that lets us down is whenever he needs to adjust any of the HTML design. For that part he's dependent on me to deploy those changes to the production server.

We use ASP MVC and Razor templates.

Has anyone successfully worked out if its possible to host our cshtml razor templates in an s3 bucket rather than on our production server?

EDIT: We wouldn't want to host all of our view templates on s3, just a few that change regularly.

tereško
  • 58,060
  • 25
  • 98
  • 150
mattdlong
  • 876
  • 2
  • 7
  • 19

3 Answers3

1

You can try implementing custom Razor engine. The base engine has overridable CreatePartialView, CreateView ETC methods which you can override and return an instance of IView with content fetched from S3.

Caution: you should not use this on a production server because it may have a performance hit. Also, make sure you have S3 bucket as private otherwise your server-side razor code will be accessible to anyone which is dangerous.

Community
  • 1
  • 1
Varun K
  • 3,593
  • 2
  • 25
  • 26
0

You can sure host them in S3, as you already do. Moreover, you could definitely write code that would download and compile these templates on-demand, but it would be a non-trivial task. You will want to implement a VirtualPathProvider.

It sounds like you should consider using a versioning system. In addition to solving the problem you describe above, a versioning system would ensure that

  • you can track who changed what when
  • you have a full history and can undo changes
  • you are alerted if you and your mate make conflicting changes to a file
  • you always know what is "the newest version"

Many systems even allow you to deploy your code directly from the versioning system.

There are dozens of versioning system services online and most of them provide their services for free for teams of your size. Take a look at Microsoft's hosted TFS, BitBucket or GitHub.

If you have never worked with versioning systems you will need to learn a few new concepts and terms. However, it won't take long and it will be soo worth it.

Rune
  • 8,340
  • 3
  • 34
  • 47
  • Yes, of course we already use version control. We don't necessarily want our view deployed to production everytime we make a commit. – mattdlong Aug 12 '13 at 06:55
  • Yep, but my questions didn't have anything to do with automated deployment, so while I appreciate the time you took to answer the question, you completely missed the point. – mattdlong Aug 13 '13 at 06:22
0

Generally view files are smaller in size than the assets - Images, JavaScript and CSS Files. You may keep the view files on the server and keep the assets on Amazon S3.

This would reduce the load from the server. Also, with this you might do well with public buckets only as most of the assets would probably be accessible publically (without authentication).

This is not an exact solution of what was asked in the question. It is just an alternative suggestion and should be treated accordingly.

Vivek Jain
  • 3,811
  • 6
  • 30
  • 47