Introduction

I was looking around for some information on how best to add the AssemblyVersion to an MVC site. In the end I thought I'd do it my self as it can't be too difficult. It wasn't and I've included how to do it in this post to help other people out.
Adding a Helper Class to MVC project
The first thing to do is add a Helper class to your existing project. I decided not to use a namespace so I didn't have to import the namespace into the View.
using System; using System.Web.Mvc; using System.Reflection; // // No Namespace // public static class VersionHelper { /// <summary> /// Return the Current Version from the AssemblyInfo.cs file. /// </summary> public static string CurrentVersion(this HtmlHelper helper) { try { System.Version version = Assembly.GetExecutingAssembly().GetName().Version; return version.Major + "." + version.Minor + "." + version.Build; } catch (Exception) { return "?.?.?"; } } }
Adding the Code to your view
Once you've added the above Html helper class you'll be able to reference the CurrentVersion() Method using intellisense.
<span>Version <%=Html.CurrentVersion() %></span>
Conclusion
That's it. You can now reference the version from anywhere in any of your views. Here is what it looks like on the default MVC project.
Also if you want the code, you can download it from here.
Made a slight modification to your code by putting it into the constructor of a Lazy object, like so.
ReplyDeleteprivate static Lazy version = new Lazy(() =>
{
try
{
System.Version version = Assembly.GetExecutingAssembly().GetName().Version;
return String.Format("{0}.{1}.{2}.{3}",
version.Major,
version.Minor,
version.Build,
version.Revision);
}
catch (Exception)
{
return "?.?.?.?";
};
});
///
/// Returns the Current Version from the AssemblyInfo.cs file.
///
public static string CurrentVersion(this HtmlHelper helper)
{
return version.Value;
}
This guarantees that the code only runs once per and not every time a page is rendered. It's a small optimization, but I figured there is no reason to calculate the same value repeatedly.
This might interest those who call their helper from a separate project and do not receive the correct version number: http://stackoverflow.com/a/2815382/41211
ReplyDeleteExcellent post.I would like to learn more about this topic.Keep sharing.
ReplyDeleteRegards,
DOTNET Training in Chennai | DOTNET course in Chennai | DOTNET Training Institute in Chennai
nice post
ReplyDeleteHi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
ReplyDeleteor Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.
hi there,i got wanted to me.so thanks for that.be helpful
ReplyDeletedot net training chennai
Embedded Training in Chennai | Best Embedded Training in Chennai | Embedded System Training in Chennai | Embedded System Training Institute in Chennai | Best Embedded System Training Institute in Chennai | Embedded Course in Chennai | Embedded System Training Institutes in Chennai | Embedded System Training Center in Chennai | Best Embedded System Training in Chennai | Embedded Systems Training in Chennai
ReplyDeleteI simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
ReplyDeletedot net training in chennai | dot net training institute in chennai | dot net course in chennai | .NET Training Center in Chennai
| Best .NET Course in Chennai with placements
You can download it from here Netflix Apk Download
ReplyDeletedorian rossini Its your chance now
ReplyDeleteFashion Hombre follow this blog
ReplyDelete
ReplyDeleteتنظيف منازل بالدمام تنظيف منازل بالدمام
تنظيف منازل بالاحساء تنظيف منازل بالاحساء
تنظيف منازل بمكة تنظيف منازل بمكة
تنظيف منازل بجدة تنظيف منازل بجدة
تنظيف منازل بالمدينة المنورة تنظيف منازل بالمدينة المنورة
Mechanical Sewing Machines–These are residential sewing machines with key highlights and less fasten designs. Mechanical sewing machines are the most famous and modest machines you'll run over. Source - The Daily Buzz
ReplyDeleteGood blog, its really very informative, do more blog under good concepts.
ReplyDeleteDOT NET Training in Bangalore
DOT NET Training in Chennai
DOT NET Training Institutes in Bangalore
DOT NET Course in Bangalore
Best DOT NET Training Institutes in Bangalore
DOT NET Institute in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
PHP Training in Bangalore
Wonderful Blog!!! Waiting for your upcoming data... thanks for sharing with us.
ReplyDeleteSoftware Testing Training in Chennai
software testing course in chennai
software testing course
best software testing training institute in chennai with placement
Software testing training in OMR
Software testing training in Annanagar
Big data training in chennai
JAVA Training in Chennai
Selenium Training in Chennai
JAVA Training in Chennai
Nice article, its very informative content..thanks for sharing...Waiting for the next update...
ReplyDeleteDrupal Training in Chennai
Drupal Training Course
Drupal 7 Certification
drupal training in vadapalani
drupal training in Guindy
Photoshop Classes in Chennai
clinical sas training in chennai
SAS Training in Chennai
javascript training in chennai
Hibernate Training in Chennai
Nice blog! Thanks for sharing this valuable information
ReplyDeleteBest IELTS Coaching in Bangalore
IELTS Training in Bangalore
IELTS Coaching centre in Chennai
IELTS Classes in Bangalore
IELTS Coaching in Bangalore
IELTS Coaching centre in coimbatore
IELTS Coaching in madurai
IELTS Coaching in Hyderabad
Selenium Training in Chennai
Ethical hacking course in bangalore
The number 1 online football betting website UFABET is the most popular service in Thailand. Official, online sports betting and all types of casinos. The entrance to UFABET can be played through the website or on the mobile phone. Iphone (iPhone) or Android (Android), which has a safe and professional, reliable and With standards to support Online football betting Through the internet and online casinos that have a variety of games to choose from to play.
ReplyDeleteEver thought of getting financially free in your life?
ReplyDelete.
There are so many options available in the market which will promise you to become financially free. However, they aren't ethical ways to get to the destination.
.
Well, you can get financially free in your life by playing games on UFABET and win big prizes. Visit the link and register and start gambling on your favorite sports like Football, Volleyball, and more.
Greeting someone with love is one of the meanest task specially in this hard-paced life. However, you can still do that by giving your special ones a reason to smile and love.
ReplyDeleteWell, you can greet people with various methods and one such method is by celebrating your special day with a celebrity. We all have celebrity crushes and therefore you get connected to your favourite celebrity.
You can follow this guide on how you celebrate with your celebrity. https://greetingly.home.blog/2020/06/30/how-celebrate-your-special-day-with-a-celebrity/
Excellent post.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training
Are you looking for cheap RDP? Well, you can now get monthly dedicated server hosting with DigiRDP, without any long-term commitment.
ReplyDeleteDigiRDP offers you thousands of servers in the stock ready for your business to sign-up. Choose the instant dedicated server and signup for your business.
Get all the essentials features Starting at as low as $10/mo and choose your operating system with DigiRDP.
Are you looking for Snapchat for PC?
ReplyDeleteSnapchat is one of the popular social media application present among all teenagers and youngsters.
.
Now, you can download with the help of emulator. Here are some of the tips and tricks on Snapchat https://www.syncetech.com/snapchat-for-pc/
Are you looking for Expressvpn Black Friday sale 2020 Deals?
ReplyDelete.
Well, VPN or Virtual Private Network lets you do internet surfing which is not tracked by your Internet Service Provider or ISP.
.
Now, VPN’s like ExpressVPN, TunnelBear, NordVPN are some of the best in business. However, the price of these services is quite expensive. So, here is the Black Friday VPN Deals 2020 for you.
Looking for the Best Laptop Under 40000?
ReplyDelete.
Check out NiamIndia for the latest pricing and Reviews for Best Laptops under 40000 here:- https://www.niamindia.org/best-laptop-under-40000/
I am professional Gamer working for Foriza Horizon as a Senior Consultant. i love to play games. Here is the best PC for games.
ReplyDeletehttps://www.newmeaccelerator.com/best-atx-case/
Are you looking for the
ReplyDeleteBest Noise Isolating Headphones.
well,headphones under 150 can be tricky because of the numerous options available. We aim to help you by suggesting the best wireless headphones under 150.
https://techno-stuff.com/best-noise-isolating-headphones-under-100/
I am a Interior Designer by Profession. I love to listen to music. Here is my Blog about
ReplyDeleteBuying Guide for Soundbars under 300.
It help to make good advancements in your business that helps you to feel the ultimate confidence knowing that your employees would give you the best performance. It is beneficial especially for new teams who want to do the job well. This gives them the inspiration to carry out the activities efficiently. Salesforce interview questions and answers
ReplyDeleteLooking for the Best Gaming Monitor under 20000?
ReplyDelete.
Well, if you have a high budget and looking for the best gaming monitor you have plenty of options to look and there are bunch of things which you need to keep in mind.
.
So, if you’re a newbie or even a experience user chances are your getting confused. Therefore, we are here to help you with our Top 13 Picks for the Best Monitor under 20000.
This is a fabulous article, please try to give more useful information.
ReplyDeletecloud architect certification
rpa career path
digital marketing certification
hadoop interview questions and answers
smart school management system
ReplyDeleteschool database management system
education erp software
school erp system
smart school software
hadoop training in chennai
Well, if you have a high budget and looking for the best gaming laptop you have plenty of options to look and there are bunch of things which you need to keep in mind. Tubi TV Download for PC Helpsforpc
ReplyDeleteDrilling consultants
ReplyDeleteOnline drilling consultancy
Đặt vé tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ giá bao nhiêu
gia ve tu my ve vietnam
thông tin chuyến bay từ canada về việt nam
dat ve may bay tu han quoc ve viet nam
I WAS SEARCHING FOR THIS KINDA COMPLETE INFORMATION!
ReplyDeleteTHANKS!
ELLA JAMES
Can I simply just say what a comfort to discover an individual who truly understands what they're talking about on the internet. You actually understand how to bring an issue to light and make it important. More people should read this and understand this side of your story. I was surprised you are not more popular since you most certainly have the gift.
ReplyDeleteVisit On: Buy Instagram Story Views
Kardinal Stick Siam - relx a great promotion. Express delivery in 3 hours.
ReplyDeleteufa football betting, casino, slots, lottery, direct website 1688, stable financial, 100% UFABET168.
Online Baccarat FOXZ24 Easy to apply, fast, บาคาร่า deposit-withdraw 10 seconds with the system.
Watch movies online sa-movie.com, watch new movies, series Netflix HD 4K ดูหนังออนไลน์, watch free movies on your mobile phone, Tablet, watch movies on the web.
SEE4K Watch movies, watch movies, free series, load without interruption, sharp images in HD FullHD 4k, ดูหนังใหม่ all matters, all tastes, see anywhere, anytime, on mobile phones, tablets, computers.
GangManga read manga, read manga, read manga online for free, fast loading, clear images in HD quality, อ่านการ์ตูน all titles, anywhere, anytime, on mobile, tablet, computer.
Watch live football ผลบอลสด, watch football online, link to watch live football, watch football for free.
Phenomenal Blog!!! thanks for your post and awaiting for your new updates...
ReplyDeleteDigital Marketing Course in Chennai
Digital Marketing Online Course
Digital Marketing Course in Coimbatore
This comment has been removed by the author.
ReplyDeletebest 12 inch subwoofer under 200
ReplyDeleteAmazing post.Thanks for sharing.........
ReplyDeleteIELTS Coaching in Hyderabad
IELTS Coaching in Bangalore
IELTS Coaching in Pune
IELTS Coaching in Gurgaon
IELTS Coaching in Delhi
Great post. keep sharing such a worthy information
ReplyDeletecyber security course in bangalore
cyber security training in chennai
I things and information online that you may not have heard before online.Hello there, I discovered your website via Google
ReplyDeleteeven as looking for a similar matter, your website got here up, it seems to be great. bhai aapke liye hai. lagao or jeeto.
I have bookmarked it in my google bookmarks.satta king game is drawing and guisses based mostly game, however currently
it's categorized in best, and satta king desawar is currently terribly renowned and largely taking part in game across the globe individuals ar crazy regarding this game.
But currently the foremost necessary factor is that this game is failed to follow the law and rule regulation that to follow the protocols and rule.
Now currently individuals want to rely on it, if the sport does not follow the protocols they need not play the sports however individuals are still taking part in the game,
they play the games on the QT individuals have reply on it to stop taking part in this type of games, always aid work and facilitated people that would like facilitated,
do something for your nation do forever sensible thing and be forever happy.satta kingThank you for visiting Our Website sattaking,Most probably as being our guest from Google search.Maybe you are visting here to get to know about gali satta number today.
to know gali disawar ka satta number please visting your homepage of website and scroll down . You will see boxed types information which is display satta number of respective game. There you will also see number of today yesterday satta number of such as gali disawar, new mumbai, disawar gold and lots of game you have bet on the game.
If you play your own gali disawar satta game and want us to put your own board on your website.satta kingPlease contact us on displayed number which you will find in footer section of website.
Apna game dalwane k liye hamse contact kre on google pay,phonepe, paytm jaise aap chahe pehle payment karen. aapka board instant site pr update kr diya jayega jaisi hi aapka payment done hota hai
We welcome you with open arms and very delighted to have you our website.satta kingPlease bookmark our website and stay tuned and updated to know.
you may have understood the process to play disawar satta gali game and heard about fix leak jodi disawar gali from your friends, relatives. Actaully people prefers disawar gali games as It is very popular in Indian subcontinent. and is considered illegal.
by having attached with our website .satta kingYou will find magnificient content regarding all the games.satta king We have stupendous information of satta results and gali disawar charts as the are open for public and updated.
Lets have a look at a recent news item that is quite
ReplyDeleteentertainmentbee.com
themoviesbio.com
petrefine.com
ReplyDeleteIt will be more fun, and you won't have to worry about
thepetsabout.com
happylifestyletrends.com
restaurantsnearme-opennow
Everything is going to be alright. Are we really being honest
ReplyDeletefrasesparaenamorarz.com
fras-es.com
punaisesdelit.org
groupe-sanguine.fr
meilleur-gps.fr
If you are a successful residential securityentrepreneur, celebrity, politician, or anyone with immense riches, your children are at risk, and they can become victims of kidnap at any time.
ReplyDeleteCoorg Tour
ReplyDeleteMysore Tour
Kodaikanal
ReplyDeleteHey friend, it is very well written article, thank you for the valuable and useful information you provide in this post. Keep up the good work! FYI, please check these depression, stress and anxiety related articles.
How to Build a Portfolio with ETFs, My vision for India in 2047 postcard, Essay on Unsung Heroes of Freedom Struggle
If you are learning how to sew, then here are some good resources for you. You might check them out-
ReplyDeletesinger sewing machine
how to repair sewing machine
how to thread a sewing machine
brother se625
brother xr3774
I think a lot of articles related to are disappearing someday. That's why it's very hard to find, but I'm very fortunate to read your writing. When you come to my site, I have collected articles related to 크레이지슬롯 .
ReplyDeletePG SLOT, the most attractive online slots game that is number one in the slot game industry in Thailand Which is very popular among the slot players in Thailand. PGSLOT consumes up to 70% of the slot game market percentage from all slot players in Thailand, which the new PG slots website is hot like COOKIESLOT of We are another website that takes care of and provides a full range of PG slot game camps. You can be confident that your PG slots game will never be the same again. Support for playing mobile slots games, as well as having an application that supports playing slots in full fome123
ReplyDeletei'm unequipped for perusing articles online especially as often as possible, but Im blissful I did these days. it is chosen dexterously composed, and your focuses are capably communicated. I request you agreeably, engage, dont at any point lower composing. https://crackdj.com/driver-toolkit-crack/
ReplyDeleteI understand this is one of the most significant direction for me. What's more, I'm fiery concentrating on your article. anyway need to analysis upon a few standard matters, the web webpage style is unmodified; the articles are strong. much thanks to you for the significant amount of real and reasonable express.Microsoft Office 2016 Product key Generator
ReplyDeleteYour substance material is nothing prompt of throbbing in bunches of ways. I guess this is alluring and eye-start texture. much obliged accurately a huge amount for stressing generally your substance material and your perusers. Happy Friday Quotes For Work
ReplyDeleteGreat post. keep sharing such a worthy information.
ReplyDeleteGerman Classes in Chennai
Great post. keep sharing such a worthy information.
ReplyDeleteAndroid Course in Bangalore
I have to agree with everything in this post. Thanks for useful sharing information.
ReplyDeleteinterview questions on cyber security
cyber security interview questions pdf
cyber security interview questions for freshers
cyber security interview questions for experienced
Mechanical Project in Coimbatore
ReplyDeleteMechanical Autocad Training
Autocad Mechanical Course
Autocad Online Course for Mechanical
Autocad Course for Mechanical Engineering
Cadd Center Courses for Mechanical
Autocad for Mechanical Engineering Courses
Mechanical Cad Training
Cad Course for Mechanical Engineer
Cadd Center Courses for Mechanical Fees
Nice Blog
ReplyDeleteMechanical Project in Coimbatore
Mechanical Autocad Training
Autocad Mechanical Course
Autocad Online Course for Mechanical
Autocad Course for Mechanical Engineering
Cadd Center Courses for Mechanical
Autocad for Mechanical Engineering Courses
Mechanical Cad Training
Cad Course for Mechanical Engineer
Cadd Center Courses for Mechanical Fees