– ASP.NET MVC Url Shortener for Bible References

April 1, 2011 | .NET, Bible Tools, JavaScript | 60 Comments

Last week, I turned a URL shortening website called which is a play on the word “Bible” and the popular URL shortener It has two main functions: A Bible URL shortener and a Bible version popup detector for any website.

1. URL Shortener let’s you easily create short URLs to Bible verses for use on Twitter and Facebook. You can use the interface you see below or just type in something that looks like a Bible verse after

When someone clicks a link, they see the Biblical text and get links to several Bible

2. Bible Refernece Popup

You can also add to a site by adding the following two lines of code to your own site

<script src=""></script>
<link href="" rel="stylesheet" />

This script will find all Bible references like these Mark 5:36; John 3:16; Eph 2:8-9 and create links to the main site along with a popup so you can read the text.

How I Built It

I chose to use ASP.NET MVC 3.0 because it makes this kind of URL handling pretty easy and because I wanted the Bible parsing code to look pretty close in both JavaScript and the server-side language (C#). I fooled around with doing the site in node.js, but decided that I wasn’t confident enough in my node.js skills to pull it off and get it properly hosted.

So what follows are my notes about how the site works and how ASP.NET MVC made it really easy to build.

URL design

The site needs to have two kinds of URLs:

  1. Fixed pages – I needed a few normal pages like Home, Plugins, and Contact that will look like this:
  2. Parsed URLs – All the other URLs will need to be checked to see if they are a valid Bible Reference. has to check if the URL is a valid id in its enormous database, but we need to actually attempt to read the URL and see if it makes sense as a Bible verse. for John 3:16 for Genesis 12:1-3 for 1 Chronicles 11:22 in the ESV needs to throw a 404 error.

Controller Setup

Getting this to work was actually really easy once I figured it out. Basically, I hard coded the paths to the static pages in one controller and then setup another controller as a wildcard URL handler.


To handle the Bible references, I used wildcard mapping. The only problem with that is that it breaks the normal “{controller}/{action}/{id}” which usually hooks up a root/home page. This means I needed to manually hook up the “Fixed pages” above.

// Map the home page
     "home", "", new { controller = "Home", action = "Index"}

// Map all sub pages
foreach(String route in new string[] { "About", "Contact", "Plugins", "Feedback" }) {
           "page_" + route, route.ToLower(),
           new { controller = "Home", action = route }

// Send everything else to the Reference controller to parse
     "verses", "{*referencetext}",
     new { controller = "Verses", action = "Show"}


This one is pretty boring. It’s just a list of Views and one post handler for the Contact form.


This controller has two actions: Show and NotFound. The Show action attempts to parse the URL into a Bible reference. If it’s successful, it shows a page. If not, you get a 404 error page. This could have been handled in the Global.asax with a UrlConstraint, but I thought this was clearer.

public ActionResult Show(string referencetext) {

     // parse the reference
     Reference reference = ReferenceParser.Parse(referencetext);

     // if it didn’t parse, show the not found View
     if (reference == null) {
           Response.StatusCode = 404;
          return View("NotFound");

     // show the view, using the reference object as the model
     return View(reference);

public ActionResult NotFound() {
     Response.StatusCode = 404;
     return View();

URLs with a Colon (:) Character

Technically, you’re not supposed to use the colon character in a URL without escaping it. But it’s very common to use a colon to separate a chapter and a verse when giving a Bible reference (2 Cor 5:17; Rev. 22:1-4) so I wanted to understand the colon character if someone chose to use it.

ASP.NET, however, disallows the colon character (and five other no-nos) by default. To allow colons, you just have to edit the following line in the web.config file.

Default requestPathInvalidCharacters value

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,:,%,&amp;,\"/>

With the colon removed.

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,:,%,&amp;,\"/>

Wrap Up

Hope that gives a basic sense of how the site works. There is a little more code on the C# side to help manage the versions and Bible website links, but the rest of the site’s functionality is mostly just simple HTML and CSS controlled by JavaScript utilizing JSONP to get the Biblical text from their content providers.

60 responses to “ – ASP.NET MVC Url Shortener for Bible References”

  1. Nice post John, Thanks.

    So we can easily integrate it on our site or blog. Any idea for the usage it in blog engine ?

  2. John Dyer says:

    @jitendra, yes you can easily add it to your site by just including the script tag above in the header of your site. You can use BlogEngine’s advanced settings to add it in the same place where you add analytics code.

  3. Jeff Lewis says:

    Awesome! Makes me wish I still had my site running…

  4. Steve Hiner says:

    You rock. That is so cool and such a fantastic idea. Thank you for making this, I’m starting to spread the word.

    P.S. Your final code line “With the colon removed.” still has the colon in it. 😉

  5. dny says:

    please support local languages as youversion does.
    so we can show bible verses in our own languages.


  6. What’s up to every one, as I am genuinely eager of reading this web site’s post to be updated regularly.
    It includes fastidious information.

  7. Howdy! I could have sworn I’ve visited this blog before but after looking at many of the
    posts I realized it’s new to me. Regardless, I’m certainly happy
    I discovered it and I’ll be bookmarking it and checking back frequently!

  8. WOW just what I was looking for. Came here by searching for split air conditioners

  9. Hi there everybody, here every person is sharing these kinds of experience,
    so it’s nice to read this webpage, and I used to pay a visit this weblog daily.

  10. Hi there! Do you use Twitter? I’d like to follow
    you if that would be okay. I’m undoubtedly enjoying your blog and look
    forward to new updates.

  11. Projects like replacement of roofing system require permits, while repairs do
    not. For various reasons ranging from all time low real estate prices to high volumes of capital opportunity, here is a list
    of the top ten cities to start a business today. Green roofs are types of roofs which contain moss, grass, and
    other kinds of plants growing on the surface.

    Review my web page siding or Paint

  12. Dianna says:

    Hello there! Do you use Twitter? I’d like to follow you if that would be okay.
    I’m definitely enjoying your blog and look forward to new posts.

  13. This site really has all of the info I needed about this subject and didn’t know who to ask.

  14. Amazing blog! Is your theme custom made or did you download it from
    somewhere? A theme like yours with a few simple adjustements would really make
    my blog jump out. Please let me know where you got your design. With thanks

  15. Thankfulness to my father who shared with me about this website, this blog is really remarkable.

  16. Hi! I just want to offer you a big thumbbs up forr thee excellent information you havee goot here on this
    post. I’ll be coming back to your web site for more soon.

  17. Hello my loved one! I wish to say that this post is
    awesome, great written and include approximately all important
    infos. I would like to see more posts like this .

  18. Thanks for finally talking about > – ASP.NET
    MVC Url Shortener for Bible References | John Dyer’s Code < Loved it!

  19. Congressional Republicans held a hearing on Abound Solar shortly after the company filed for bankruptcy.

    They should do that even if they only suspect medical malpractice, considering tha attorneys
    usually offer an initial free consultation. Eery year all around the pleading world, there are thousands of people get ill, the world is narrowing for a human life, advancement has given fruuts to us bbut
    alo ring us the fears of global warming, pollution, and the ever increasing rate of newer diseases.

  20. It’s amazing in favor of me to have a website,
    which is useful designed for my know-how. thanks

  21. Tracy says:

    Greetings from Florida! I’m bored to tears at work
    so I decided to check out your website on my iphone during lunch break.

    I enjoy the info you provide here and can’t wait to take a look when I get
    home. I’m surprised at how quick your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyways, excellent blog!

    my weblog … Codici Xbox Live Gratis (Tracy)

  22. Then after that they can decide to option for a third
    year. Knowing the right keyboard shortcuts will fix this problem.
    Keypad includes the buttons for dual view, home screen and bookmark.

  23. Now I am going away to do my breakfast, after having my breakfast coming over again to read more news.

  24. What’s up i am kavin, its my first occasion to commenting anywhere,
    when i read this post i thought i could also make comment due to
    this brilliant paragraph.

  25. An interesting discussion is worth comment.
    I do believe that you should publish more about this issue, it may not be a taboo matter but
    usually people don’t talk about such topics.
    To the next! Cheers!!

  26. Do you mind if I quote a few of your posts as long as I
    provide credit and sources back to your webpage? My blog is in the very same area of
    interest as yours and my visitors would truly benefit from some of the information yyou present here.
    Please let me know if this okay with you. Regards!

  27. Máte nízké sebevědomí ɑ myslíte sі, že nemáte na to, abyste sii na internetfu našli sexy protejšek ppro sex v
    Brně na jednu noc, ale tɑ představa vám nedává spát.
    Nikdo neríká, žе máte hledat jen jednoho sexy partnera – známosti na Seznamce neznají mezí
    ɑ jestli se na to cítíte, domluvte sі treba sex vve trech.
    Singles z Ostravy а celé Ceské republiky se obracejí na seznamky а podobné
    služby, protože mají príliš rušný život na tο, aby nekoho hledai v
    гeálném živote.

  28. perceraian says:

    This post is in fact a pleasant one it assists new the web users, who
    are wishing for blogging.

    Look at my webpage; perceraian

  29. I am thinking of filing chapter 7 bankruptcy yet I don’t know how you can begin. I think I much better employ a lawyer. It is so frustrating. I was doing a look for chapter 7 bankruptcy and also discovered Much appreciation for the info. Thank you. Wagoner.

  30. Just wish to say your article is as astonishing.
    The clarity in your post is simply nice and i can assume you’re an expert on this subject.
    Well with your permission let me to grab your RSS feed to keep
    up to date with forthcoming post. Thanks a million and please carry
    on the gratifying work.

  31. I’m now not positive where you’re getting your information,
    but great topic. I must spend some time studying much more
    or understanding more. Thank you for magnificent information I was looking for this info for my mission.

  32. Quality articles is the secret to invite the people to pay a visit the web site,
    that’s what this web page is providing.

  33. says:

    Hello, everything is going well here and ofcourse every
    one is sharing data, that’s truly fine, keep up writing.

  34. You actually make it appear really easy along with your presentation however I in finding this topic to be really something
    which I think I’d by no means understand. It sort of feels too complex and extremely extensive
    for me. I’m looking ahead on your next put up, I will attempt to get the dangle of it!

  35. I enjoy what you guys are up too. Such clever work and coverage!

    Keep up the superb works guys I’ve incorporated you guys to my personal blogroll.

  36. Ben says:

    Nice post. I learn something new and challenging on sites
    I stumbleupon on a daily basis. It’s always interesting to read
    content from other authors and use something from
    their websites.

  37. Randell says:

    What you said was actually very logical. However, think about this, suppose
    you typed a catchier title? I mean, I don’t wish to tell you
    how to run your website, however what if you added a headline that makes people want more?
    I mean – ASP.NET MVC Url Shortener for
    Bible References | John Dyer’s Code is kinda plain. You should look at Yahoo’s front
    page and note how they create article titles to grab viewers to click.
    You might try adding a video or a pic or two to grab readers interested about everything’ve written. Just my opinion, it would make your website a little bit more interesting.

  38. Sal says:

    Because the admin of this site is working, no
    doubt very soon it will be well-known, due to its quality contents.

  39. I think the admin of this web site is actually working hard in support of his web site, because here every
    material is quality based material.

  40. Cheri says:

    Hey There. I found your blog the use of msn. That is a really
    neatly written article. I’ll be sure to bookmark it and
    come back to read extra of your helpful info. Thanks for the post.

    I’ll certainly comeback.

  41. Gemma says:

    I think what you said made a lot of sense.
    But, think on this, suppose you added a little content? I ain’t saying your content is not
    good, however what if you added a headline to possibly get a person’s attention? I mean – ASP.NET MVC Url Shortener for Bible References | John Dyer’s Code is kinda plain. You might look at
    Yahoo’s front page and note how they create post headlines to
    get people interested. You might add a video or
    a picture or two to get readers excited about everything’ve written.
    In my opinion, it might bring your website a little bit more

  42. Hi there, constantly i used to check weblog posts here early in the daylight, for
    the reason that i love to find out more and more.

  43. Can I just say what a comfort to find a person that genuinely understands what they’re discussing over the
    internet. You certainly realize how to bring an issue to light and make it important.
    A lot more people really need to look at this and understand this side of the story.
    I was surprised you aren’t more popular because
    you certainly possess the gift.

  44. I just like the helpful information you supply
    in your articles. I’ll bookmark your blog and
    take a look at once more right here regularly. I’m fairly certain I’ll learn plenty of new stuff proper here!
    Good luck for the next!

  45. I’ve been surfing online greater than 3 hours as of late,
    yet I by no means discovered any fascinating article like yours.

    It is lovely worth sufficient for me. In my opinion, if all webmasters
    and bloggers made good content as you probably did, the web might be much more useful than ever before.

  46. It’s an remarkable piece of writing in support of all the web people; they will take advantage from it I am sure.

  47. Hello to every one, for the reason that I am really keen of reading this webpage’s post to be updated daily.
    It consists of nice material.

  48. Net says:

    Great Article

  49. says:

    Hey, I think your website might be having browser compatibility issues.
    When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it
    has some overlapping. I just wanted to give you a quick heads up!

    Other then that, amazing blog!

  50. you are actually a good webmaster. The site loading
    pace is incredible. It seems that you are doing any distinctive trick.
    Also, The contents are masterwork. you’ve done a wonderful activity on this topic!

  51. Mirta says:

    Spiele wie Book of Ra Deluxe, Lucky Lady’s Charm, Sizzling Hot Deluxe
    sowie viele andere unterhaltsame Spielautomaten!

  52. Hello! I could have sworn I’ve been to this site before but after looking
    at a few of the posts I realized it’s new to me. Nonetheless, I’m certainly pleased I found it and I’ll be book-marking it
    and checking back frequently!

  53. Manuel says:

    Kualitas – Pastikan bahwa perusahaan Anda telah
    memilih manpu memberikan layanan berkualitas . Bisnis ini memiliki lanjutan dubuat informasi dengan membuat semua jenis Dunia jurnal bersih Wide
    yaqng memfasilitrasi perusahaan mempromosikan solusi
    & produk dan layanan dari sebagian besar ahli lebih lanjnut sebagai cara trendi
    . Ada berbagai kerangka kerja PHP yang tersedia di pasar yang
    membantu menyimpan sejumlah besarr waktu Anda.

  54. Stamp says:

    If you already get Food Stamps and need help, contact the Food
    Stamp Center where your case is currently serviced.

  55. Nilson says:

    Ok, as much as I hate to admit this, I have girls. When I say girls I mean my cleaning ldieas. They come twice a month to do all the dirty work for me. I love them but I think they need one of these chore charts! It bugs me to no end when they forget to do something!

  56. 菠菜网 says:


  57. I’ve been looking for a post like this for an age

  58. Author: Ronald Senn, VP Ideal Wine Coolers, October 2009.
    This type of a company will also have a detailed ordering
    system. According to a recent nationwide study conducted
    by LG Electronics, 95 percent of homeowners stated they would be willing to give up something they enjoy
    for 12 months in exchange for upgraded kitchen appliances.
    Cooking can take a significant portion out of your monthly budget, but so,
    too, can the appliances in your kitchen. 6) Pantry closet storage solutions like wire
    racks and dividers work wonders when organizing a
    pantry, they not only keep everything on display but they also give your pantry a neat

  59. Hi everyone, it’s my first pay a quick visit at this website, and post is actually fruitful designed for me, keep
    up posting such content.

Hi, I'm John Dyer. In my day job, I build websites and create online seminary software for a seminary in Dallas. I also like to release open source tools including a pretty popular HTML5 video player and build tools that help people find best bible commentaries and do bible study. And just for fun, I also wrote a book on the theology of technology and media.

Fork me on GitHub

Social Widgets powered by