How to fix Cross-Origin Request Blocked: (Reason: CORS preflight channel did not succeed)"NetworkError: 405 Method Not Allowed when calling post method from angular.js with web apiCross-Origin Request Blocked: (Reason: CORS preflight channel did not succeed). in FifoxI am getting error:(Cross-Origin Request Blocked) angular 2 ionic 2CORS preflight channel did not succeed when posting DataRequest Options Error and Bad Request ErrorCross-Origin Request Blocked when sending postHow to bypass the cross origin error using angular 6 (Firefox CORS Error, Chrome Preflight Error)AllowAnyMethod works for some API calls but not for othersData fetch problem in IONIC 3 from a woocommerce local site database.The Same Origin Policy disallows reading the remote resourceCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (URL)
Cathode rays and the cathode rays tube
The significance of kelvin as a unit of absolute temperature
So a part of my house disappeared... But not because of a chunk resetting
Why do radiation hardened IC packages often have long leads?
Does putting salt first make it easier for attacker to bruteforce the hash?
Command of files and size
Why did the World Bank set the global poverty line at $1.90?
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
Is there a DSLR/mirorless camera with minimal options like a classic, simple SLR?
What differences exist between adamantine and adamantite in all editions of D&D?
Can you make an identity from this product?
Does a (nice) centerless group always have a centerless profinite completion?
A Salute to Poetry
Should I put programming books I wrote a few years ago on my resume?
Why isn't Bash trap working if output is redirected to stdout?
How to avoid typing 'git' at the begining of every Git command
noalign caused by multirow and colors
Cooling tower for nuclear power plants
C++ logging library
Increase speed altering column on large table to NON NULL
How was the airlock installed on the Space Shuttle mid deck?
Trying to get (more) accurate readings from thermistor (electronics, math, and code inside)
Extracting data from Plot
Make Gimbap cutter
How to fix Cross-Origin Request Blocked: (Reason: CORS preflight channel did not succeed)
"NetworkError: 405 Method Not Allowed when calling post method from angular.js with web apiCross-Origin Request Blocked: (Reason: CORS preflight channel did not succeed). in FifoxI am getting error:(Cross-Origin Request Blocked) angular 2 ionic 2CORS preflight channel did not succeed when posting DataRequest Options Error and Bad Request ErrorCross-Origin Request Blocked when sending postHow to bypass the cross origin error using angular 6 (Firefox CORS Error, Chrome Preflight Error)AllowAnyMethod works for some API calls but not for othersData fetch problem in IONIC 3 from a woocommerce local site database.The Same Origin Policy disallows reading the remote resourceCross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (URL)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've built a Server side with Web-API calls to get data from Angular app,
My register page is getting the data fine but it never reaches the server-side,
The following error keeps occurring:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS preflight channel did not succeed).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS request did not succeed).[Learn More]
ERROR
Object headers: …, status: 0, statusText: "Unknown Error", url: "http://localhost:58972/api/user/", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost:58972/api/user/: 0 Unknown Error", error: error
angular asp.net-web-api
add a comment |
I've built a Server side with Web-API calls to get data from Angular app,
My register page is getting the data fine but it never reaches the server-side,
The following error keeps occurring:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS preflight channel did not succeed).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS request did not succeed).[Learn More]
ERROR
Object headers: …, status: 0, statusText: "Unknown Error", url: "http://localhost:58972/api/user/", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost:58972/api/user/: 0 Unknown Error", error: error
angular asp.net-web-api
add a comment |
I've built a Server side with Web-API calls to get data from Angular app,
My register page is getting the data fine but it never reaches the server-side,
The following error keeps occurring:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS preflight channel did not succeed).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS request did not succeed).[Learn More]
ERROR
Object headers: …, status: 0, statusText: "Unknown Error", url: "http://localhost:58972/api/user/", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost:58972/api/user/: 0 Unknown Error", error: error
angular asp.net-web-api
I've built a Server side with Web-API calls to get data from Angular app,
My register page is getting the data fine but it never reaches the server-side,
The following error keeps occurring:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS preflight channel did not succeed).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:58972/api/user/. (Reason: CORS request did not succeed).[Learn More]
ERROR
Object headers: …, status: 0, statusText: "Unknown Error", url: "http://localhost:58972/api/user/", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost:58972/api/user/: 0 Unknown Error", error: error
angular asp.net-web-api
angular asp.net-web-api
edited Mar 24 at 22:29
dince12
2,6333723
2,6333723
asked Mar 24 at 21:49
O. DrorO. Dror
113
113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Add config.EnableCors(); in Register method in WebApiConfig.cs file
In angular side add the "access-control-allow-origin" HttpHeader
If you are using owin with token base authentication then
install this nuget package https://www.nuget.org/packages/Microsoft.Owin.Cors/ and add app.UseCors(CorsOptions.AllowAll); in Startup File under configuration method.
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328913%2fhow-to-fix-cross-origin-request-blocked-reason-cors-preflight-channel-did-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add config.EnableCors(); in Register method in WebApiConfig.cs file
In angular side add the "access-control-allow-origin" HttpHeader
If you are using owin with token base authentication then
install this nuget package https://www.nuget.org/packages/Microsoft.Owin.Cors/ and add app.UseCors(CorsOptions.AllowAll); in Startup File under configuration method.
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
add a comment |
Add config.EnableCors(); in Register method in WebApiConfig.cs file
In angular side add the "access-control-allow-origin" HttpHeader
If you are using owin with token base authentication then
install this nuget package https://www.nuget.org/packages/Microsoft.Owin.Cors/ and add app.UseCors(CorsOptions.AllowAll); in Startup File under configuration method.
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
add a comment |
Add config.EnableCors(); in Register method in WebApiConfig.cs file
In angular side add the "access-control-allow-origin" HttpHeader
If you are using owin with token base authentication then
install this nuget package https://www.nuget.org/packages/Microsoft.Owin.Cors/ and add app.UseCors(CorsOptions.AllowAll); in Startup File under configuration method.
Add config.EnableCors(); in Register method in WebApiConfig.cs file
In angular side add the "access-control-allow-origin" HttpHeader
If you are using owin with token base authentication then
install this nuget package https://www.nuget.org/packages/Microsoft.Owin.Cors/ and add app.UseCors(CorsOptions.AllowAll); in Startup File under configuration method.
answered Mar 25 at 1:19
Sajitha WattageSajitha Wattage
313
313
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
add a comment |
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
hey I was trying to put the method EnablCors(), but the config doesn't have it, should I implement it?, and where exactly i need to put the HttpHeader?
– O. Dror
Mar 25 at 21:12
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
are you using owin token based authentication?
– Sajitha Wattage
Mar 26 at 1:03
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Please add the Microsoft.AspNet.WebApi.Cors from nuget. Sorry I haven't mentioned that in original answer.
– Sajitha Wattage
Mar 26 at 1:54
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
Steps 1. Add nuget package Microsoft.AspNet.WebApi.Cors 2. add config.EnableCors(); in WebApiConfig.cs file under Register method. 3. add [EnableCors(origins: "", headers: "", methods: "*")] on top of your method
– Sajitha Wattage
Mar 26 at 2:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328913%2fhow-to-fix-cross-origin-request-blocked-reason-cors-preflight-channel-did-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown