find a location for property in a new city

Tuesday, 22 December 2015

Stop processing OPTIONS requests for CORS in ASP.NET Web API

I was attempting to allow some particular origins to access my ASP.NET Web API from a client side single page application. I was using the EnableCorsAttribute that comes with the Microsoft.AspNet.WebApi.Cors NuGet package.

I managed to set up CORS using the following code in my WebApiConfig:

var origins = ConfigurationManager.AppSettings["AllowedOrigins"];
var cors = new EnableCorsAttribute(origins, "accept,content-type,origin,customId", "GET,POST,PUT");

There is quite a lot to CORS but essentially, (some browsers) send a pre-flight request recognised with its HTTP method OPTIONS. This basically asks the application who is allowed to access this URL with the attempted headers and HTTP method. Your Web API will respond saying which origins are allowed or if there are any errors. The browser then decides if it is one of those allowed origins and sends the request if it is.

The problem I found is that on this initial OPTIONS request my IoC container, Unity, was constructing a whole dependency chain of classes. Some of which access the database and some check HTTP headers. This was throwing an error since bits were missing from the HTTP headers that would be with normal requests and unnecessarily hitting the database. So really, I wanted to stop these requests in their tracks whilst making sure they did their intended pre-flight work.

The best way I found to do this was to ignore routes based on an HTTP constraint for "OPTIONS". Basically shove this in your routing:

var constraints = new { httpMethod = new HttpMethodConstraint(HttpMethod.Options) };
config.Routes.IgnoreRoute("OPTIONS", "{*pathInfo}", constraints);

More info on Enabling CORS in Web API.

Follow britishdev on Twitter


  1. Good post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it!buy female viagra

    1. Hi, 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.

    2. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.

    SAP training in Chennai

  3. Beautiful post just there, and i've bookmarked this blog too & keep up the great job.

  4. When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile.
    Friv2Games, Kizi 6 Games, Yepi Games, Unblocked Craft, Friv, Y8Y8co, Y3 Game, Frozen Games, Y8Y8, Kizi, tetris battle, Friv, Y8Y8 co


  5. Thanks for posting this useful content, Good to know about new things here, Let me share this, . Hadoop training in pune

  6. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

    happy wheels | monkey go happy|  unblocked games

  7. wheels happy wheels happy Total Jerkface Total Jerkface Happy old man demo happy wheels game||happy Total Jerkface happy Total Jerkface||happy wheels unblocked happy wheels demo total jerkface
    Play card games || spider solitaire

  8. Thank you for this valuable information. The information you shared is very interesting. Brave Technologies is an leading erp software development company in chennai.
    enterprise resource planning in chennai | web design company in chennai

  9. I often get emotionally involved. Like when I read your post, I can cry, laugh, sad, funny, depending on your written words. I think you are a sensitive person.

  10. This article is really fantastic and thanks for sharing the valuable post.

  11. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.

  12. Every good is always in my sight, and if I know how to choose fun or not is the new thing to say. Come with unblocked, abcya or titanfall or xbox one. have fun.
    .xbox one | ABCya 5 games

  13. Awesome review, I'm certain you're getting an extraordinary reaction.
    Amazing and intriguing article. Extraordinary things you've generally imparted to us. Much appreciated. Simply keep making this kind out of post. total jerkface

  14. Interesting post! This is really helpful for me. I like it! Thanks for sharing!

    suchmaschinenmarketing lüdenscheid

  15. Well, it went the way I need you on the phone a long moment ago. I’m glad I could help. You can Also check my site happy wheels total jerkface


  17. Well, it went the way I need you on the phone a long moment ago. I’m glad I could help. You can Also check my site unblocked games

  18. i love this Blog
    check this same

  19. Nice blog too informative. Looking and reading your points it’s so impressive. Doing more blog like this.Web Development Company in Chennai

  20. A very important article! Sure your next post will be as great as this. And if you want to find best premium wordpress templates for any kind of business go here

  21. Thank you for your contribution during the last time
    Friv 2 Games
    Yepi Games

  22. Here you can dowload drivers and find useful information about them.

  23. Want to be cool like me to spend my day off? Go on the link there you can have a good time and earn some extra money beneficial casino on net I wish good luck

  24. Packers and Movers Bangalore as a Services providing company can make all the difference to your ###Home Relocation experience. Bangalore based Company which offers versatile solutions, Right team that easily reduce the stress associated with a ✔✔✔Household Shifting, ***Vehicle Transportation. we help things run smoothly and reduce breakages and offer you seamless, Affordable, Reliable Shifting Services, Compare Shifting Charges @
    Packers And Movers Bangalore

  25. Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔✔✔Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @
    Packers And Movers Chennai

  26. You are sharing informative post keep blogging, Thanks you. I have a common issue for my this website eyeglass lens replacement

  27. Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.

  28. Buy Premium lawn Online for Women's at best prices available at Motifz. ✓ Latest Fashion, ✓ Trendy Designs ➤ Shop Now!

  29. Check the Bihar Board 10th Result 2019 Details here. The Bihar School Education Board (BSEB) has announced the Bihar Board Class 10 Results 2018 on June 26 at 4.30 pm. The Board had earlier announced the Bihar Board Class 12 Result on June 6, 2018.

    MP Board 10th result 2019 will be available in the month of May. MPBSE conducts the 10th class examinations in the month of March.

    Are your looking for Karnataka SSLC result 2019? Students from the Karnataka Board appeared for the examinations are in seek of their upcoming result.

    The West Bengal Board of Secondary Education (WBBSE) will declare the West Bengal Board 10th Result 2019. As of now there is no official news on the release of the madhyamik Result 2019.

  30. That is intriguing; you are an extremely gifted blogger. I have shared your site in my interpersonal organizations! A decent guide. I will pursue these tips. Much obliged to you for sharing such point by point article.


    review for loans

    +18882623768 Delta customer number for
    Technical Support


    Cargo Department

    Customer Service

    Lost Baggage

    Medallion Status
    24 hours, 7 days
    Delta customer service.
    Get in touch with Delta’s customer service department through the following phone numbers,
    email and contact form.
    For more information about reservations, technical support, cargo department,
    lost baggage and medallion status, please call the numbers listed Above .
    Delta Airlines Customer Service
    Indian e Visa Online
    I-visa online


  32. Quickbooks Enterprise Support Phone Number
    Get Help for all your issues with QuickBooks Enterprise.
    Call (888) 802-9333
    Call Intuit QuickBooks Online Customer Services Helpline Phone Number USA 1-888-802-9333 to fix your Accounting Issues.
    QuickBooks Technical Support Contact Team Will fixes your issue Enterprises,
    Payroll, Pro, Premier, Vat, Bank Errors etc , QuickBooks Online Support Number 1-888-802-9333 USA

  33. +1 (888) 262-3763 Delta Airlines Customer Service Number for :

    Delta Airline Reservatations

    Airline Booking

    PNR Change

    Online Delta Ticket Booking

    Delta Customer Care

    Best phone number to reach Delta

    Airline VIP Lounge

    Delta Celebrity Reservation

    24 hours, 7 days
    Delta customer service number .
    Get in touch with Delta’s customer service department through the following phone numbers,email and contact form.
    For more information about reservations, technical support, cargo department, lost baggage and medallion status, please call the numbers listed Above .

    Delta Customer Service Number
    Delta Flight Reservation Number
    Delta Customer Service
    Delta Customer Number
    Delta Service Number
    Delta Airlines Reservation Number

  34. very nice post


    Apply India EVisa from your home country Online.
    No need to visit Embassy and No more worries about document and application validation.
    Evisa India can be now applied Online by visiting
    - Click on Apply eVisa or Begin Application
    - Start filling the first form with Basic Details for applying Indian eVisa
    - Complete form 2 and form 3
    - Make Payment and Upload Documents
    -Submit Your eVisa Application.
    - Wait for Confirmation email.
    - Your evisa India is applied Successfully
    - Find your eVisa India in your email.

  36. This is really wonderful. Kudos to you! If you want to Make your life happy with Love Tarot Card readings, use Tarot Life. Good and accurate.


  37. I am very happy to take services from Everyhourloans.It's one of the best loan lenders in Ireland.


  38. The 5 Best Graco Pack 'n Play chicco lullaby with bassinet + reviews. The best Graco Playards with bassinet divided into 2 groups: care-stations & traditional ..

  39. Great blog to get knowlegde about Tarot cards and zodiac sign.This one here tells you more on Which Zodiac Signs Will Be The Luckiest In 2019?

  40. sudhanshu ashram kanpur is the most famous attraction in Kanpur, here many god's temple : Lord Krishna, Lord Shiva, Goddess Radha, Goddess Parvati and Hanuman located inside the ashram. In this temple a beautiful garden located in-side the ashram. The sudhanshu ashram kanpur is located which gives peace to the mind and soul.

  41. Thank You for an amazing article, it was really helpful for me and loved to read this.
    Events Planner In Delhi
    Wedding Planner In Delhi

  42. osg777 merupakan penyedia layanan permainan Judi Slot Online yang saat ini populer dan mendapatkan kepercayaan dari banyak bettor indonesia.

    permainan slot osg777 kini anda sudah bisa mengakses permainan ini kapanpun dan dimanapun anda berada hanya menggunakan smartphone android atau ios.

    osg777 terkenal dengan permainan slot online nya, maka tidak heran permainan ini sangatlah mendominasi ketika kita sudah membahas brand yang satu ini.

    Daftar akun osg777 android juga tergolong cukup mudah dan praktis, yaitu anda hanya diminta untuk mengisi data lengkap yang anda miliki ke dalam formulir register yang sudah disediakan.

    osg777 juga menyediakan permainan slot. Permainan slot yang disajikan mendapatkan predikat tingkat kemenangan tertinggi yang sudah di akui oleh banyak member.

  43. VRN is one of the leading Offshore IT outsourcing companies in India offering Custom Software development services. Hire Virtual Employee List of best Punjabi songs (List of latest Punjabi songs), List of best Punjabi songs: Hello friends, best punjabi songs 2019, download punjabi songs, punjabi songs mp3, latest hit punjabi songs, listen punjabi songs list of Punjabi songs List of Bollywood comedy Films

  44. Nice post and useful information you have.

    If you are want to download new movies like south Hindi dubbed movie and dual audio Hindi dubbed movies from movie rulz, and then this is the place from where you can download the latest cinema.

    Download and Watch Hollywood South Hindi Dubbed

  45. Nice blog.Thanks for sharing this information.
    If you want to know about latest fashion then please visit my site:-


  46. Nice information. Thanks for sharing this informative blog with us. I really need this type of blog and I’m so lucky to found this. also visit .
    packers and movers in delhi

  47. I'm glad I found this web site, I couldn't find any knowledge on this matter prior to.Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my web site. theymakedesign


  48. The next time I read a blog, Hopefully it won't fail me as much as this one. I mean, Yes, it was my choice to read, but I genuinely thought you would probably have something helpful to say. All I hear is a bunch of whining about something you could fix if you weren't too busy seeking attention.
    Click here to get More information.

  49. Regarder en replay gratuitement vos programmes TV : films, séries (saisons et épisodes), sports, documentaires, etc. Les dernières émissions et séries diffusées par les TV en replay Pour voir ou revoir une émission de télé quand vous le voulez
    divertissement en replay streaming
    tele-realite en replay streaming
    tele en replay streaming
    Les Princes et les Princesses de l’Amour 7 en replay streaming
    La grosse rigolade en replay streaming
    Balance ton post ! en replay streaming


  50. Everything is very open with a very clear clarification of the issues.
    It was definitely informative. website
    Your site is very helpful. Thanks for sharing!

  51. hello thankyou for nice article i hope you make nice article again
    Install Aplikasi S 128APK mobile

  52. Gaurav Travel is the Top travel agencies of india with convenient locations in most major cities and Countries.

    khushi travel
    chandigarh travels
    kapoor tours and travels
    Gaurav travels
    chandigarh travel

  53. Thanks for posting
    my website techwolk is related to technology

  54. I never believed that i will be happy again after much frustration. I have been rejected by my husband after Six(6) years of marriage just because he met another woman and he left me and the kids to suffer. One day when i was reading through the web i stumbled at a post on how chief dr lucky the great spell caster has helped people to restore broken marriages and relationships and curing of diseases. I emailed him immediately to help my situation via: He told me not to worry that my husband will return to me begging and shedding tears of forgiveness. I am so happy that my husband actually returned to me in 48 hours after i obeyed the words and instructions of chief dr lucky. contact him today in any of your problems for a lasting solution via: or call/whats app +2348132777335 Website:  

  55. An outstanding share! I’ve just forwarded this onto a friend who has been conducting a little homework on this. And he actually ordered me breakfast because I discovered it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending the time to discuss this topic here on your website.
    idnplay poker

    poker p2play

    link nova88

    oriental slot

    joker123 login

    daftar poker idn

    daftar p2play

    casino sbobet

    maxbet online

    login s128

  56. After looking at a handful of the articles on your blog, I seriously appreciate your technique of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Please visit my web site as well and let me know how you feel.
    ion casino

    osg777 download

    login joker123

    oriental game apk

    poker idnplay

    daftar p2play

    login sbobet

    agen maxbet

    nova88 maxbet

    s128 live

  57. Hi there! I could have sworn I’ve visited this web site before but after browsing through many of the articles I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be bookmarking it and checking back frequently!
    judi oriental casino

    ion casino online

    login joker123

  58. I’m amazed, I must say. Seldom do I come across a blog that’s both educative and amusing, and let me tell you, you've hit the nail on the head. The issue is an issue that too few folks are speaking intelligently about. dev I'm very happy I came across this in my search for something regarding this.

  59. Hi, I do believe this is an excellent blog. I stumbledupon it ;) I am going to come back yet again since i have bookmarked it. Money and freedom is the greatest way to change gadgets, may you be rich and continue to help other people.

  60. I have learned a lot from your article and I’m looking forward to apply| Business registrations |it with my children and in my class too.

    I had no idea what a blog was or how to start one.| Financial management | I will definitely use this information in the very near future.

  61. รีวิวเว็บสล็อต Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our.

  62. Saya sangat suka blog Anda .. warna & tema yang sangat bagus.
    Apakah Anda merancang situs web ini sendiri atau apakah Anda mempekerjakan seseorang untuk melakukannya untuk Anda?
    Tolong tanyakan karena saya ingin mendesain blog saya sendiri dan
    ingin mencari tahu dari mana Anda mendapatkannya. pujian
    idn poker online terpercaya
    daftar slot terpercaya

  63. thank you for sharing this information is very helpful for me and I bookmarked your site because I found your content important for me.
    satta result
    gali satta
    disawar result
    satta matka
    satta king
    satta chart
    disawar satta result
    gali satta result
    gali result

  64. Thanks for sharing this wonderful informations.
    android training institutes in coimbatore

    amazon web services training in coimbatore

    big data training in coimbatore

    C and C++ training in coimbatore

    Blue prism training in coimbatore

    artificial intelligence training in coimbatore

    RPA Course in coimbatore

  65. I am really very happy to visit your blog. Now I am found which I actually want. I check your blog every day and try to learn something from your blog. Visit your website: Mobile app development company.

  66. if you want to pop up your website then you need unlimited email hosting

  67. I like this article.I was searching over search engines and found your blog and its really helps thank you so much @ Packers and Movers mumbai

  68. engines and found your blog and its really helps thank you
    Toko Bunga Jakarta

  69. A Certificates Quality Is In the Details

    Once you place an order on our site, we start the work of replicating your certificate. We go through our collection of certificate templates, a collection we have built over the years by replicating real certifications. We produce AAA+ grade Quality Fake Certificates with holograms, metallic Ink, IR detection, ultra-violet features; see through features and different serial numbers. These features make our certificates to be 100% undetected, 100% safe and secure.

    For more details you can visit our website: OR WhatsApp: +1(443) 351-8162 OR Email us at

  70. i am very impres of your post.


  71. Nice information. Thanks for sharing this informative blog with us. I really need this type of blog and I’m so lucky to found this. also visit .
    Packers and movers in Delhi

  72. Buy online wholesale printed custom eyelash boxes packaging at seashore packaging in affordable price at your doorstep. Get free custom quote now!!

  73. Hi, I do think this is a great site. I stumbled upon it ;) I'm going to revisit once again since i have saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help others.

    No more waste time to searching #HDimages, #PCwallpaper, #smartphone_wallpaper, #socialmedia_banner, #socialmedia_image_post, #natureHDimages, and many more awesome pictures. Just visit All Awesome Pictures Only For Love Hearts and choose your best choice.
    All Awesome Pictures Only For Love Hearts
    All Awesome Pictures Only For Love Hearts
    All Awesome Pictures Only For Love Hearts

  74. Buy Bulk CBD Hemp Flowers Online – We offer bulk flower in a couple of different strain options to choose from if you want to buy CBD flower pounds for sale. cheapest cbd hemp flower online, CBD flower pounds for sale
    buy cherry wine cbd hemp flower online
    treasure valley cbd
    does cbd oil smell like weed
    hemp flowers for sale usa
    cbd hash for sale
    hemp buds for sale usa
    what does cbd oil smell like
    wholesale cbd flower
    email ;

  75. Buy online wholesale printed custom perfume boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

  76. Thank you so much. This article was very essential for me . I after a long time I found this kind of article. know about Roobet Promo Code Gambling Bitcoin Casino


    We, the packers and dispatchers at kstar, follow a customer-oriented approach to meet the different needs of our customers. Our Delhi-based company is based on strict principles of security, integrity and reliability. We provide fast and affordable packing and moving services as well as transportation services to our clients, to meet the diverse needs of clients across India.


  78. Firstly talking about the Blog it is providing the great information providing by you . Thanks for that .Hope More articles from you . Next i want to share some information about Salesforce training in Banglore .

  79. Buy online wholesale printed custom cbd boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

  80. Vortax is Marry Land based mobile app development agency offering custom mobile solutions to business of all sizes to automate their business process.


  81. Firstly talking about the Blog it is providing the great information providing by you . Thanks for that .Hope More articles from you . Next i want to share some Information about Salesforce training in Hyderabad .

  82. Buy online wholesale custom custom candle boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

  83. This comment has been removed by the author.

  84. Buy online wholesale custom candle boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

  85. Blackbird packaging provide you with any size, shape design, lipstick boxes sooner than any other packaging competitor in the market

  86. Blackbird packaging provide you with any size, shape design, cbd boxes sooner than any other packaging competitor in the market

  87. This is an amazing blog about CBD; I was trying to figure out how to keep in contact with your blog until I found a decent iphone app for reading wordpress blogs. I really wish you to have a good day and keep with the good work! Hemp flower

  88. Did you know that you can easily view the contents of your phone on your TV without a cable? With a screen mirror app you can easily do the screen mirroring from Android to TV. Check out to find out more.

  89. Packaging town is a one-stop solution for the short-run Custom Packaging, Wholesale CBD Boxes needs, and supplies at ease.

  90. direct print mylar bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available

  91. All details you describe in your blog post about Luxury gift boxes is very informative for me. Customboxesu provides Luxury gift boxes packaging with suitable price.

  92. Custom Lotion Boxes wholesale keep your product safe form environment Custom Lotion Boxes wholesale has become beneficial for the relevant industry.

  93. Thanks for sharing this informative article. For more info about Weed monthly Subscription Boxes very beautiful article nice use of pics.

  94. Die cut box are uncommon endowments so their packaging ought to likewise be novel and imaginative.Die cut box display boxes are a perfect method to pack your product.

  95. Cream boxes is hot selling product in both season. thanks for sharing it such a brilliant information.