Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EnableCors for VB.net

Does anyone know how to put the enableCors into the controller on vb.net. i am working along with a pluralsight course and tried a code translator with no luck. my attempt is below.

<EnableCors(origins:    "http://localhost:53080", headers: "*", methods: "*")>
like image 746
user3542394 Avatar asked May 31 '26 11:05

user3542394


2 Answers

The correct syntax would be something like this:

<EnableCors("http://localhost:53080", "*","*")>

The C# example appears to use named parameters. VB.NET supports that too, however the EnableCorsAttributes has properties and contractor arguments that only differ by letter casing. This confuses the compiler as to whether you are attempting to set the named parameter or the property in the attribute. So, in this case we can just drop the named arguments all together.

like image 117
vcsjones Avatar answered Jun 03 '26 13:06

vcsjones


In Vb.net this <EnableCors("http://localhost:53080", "*","*")> will work, but, you have to add on NuGet the Microsoft.AspNet.WebApi.Cors and Microsoft.AspNet.Cors. You need to add Imports System.Web.Http.Cors on the class.

like image 27
Adson Diego Avatar answered Jun 03 '26 12:06

Adson Diego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!