Search This Blog

Tuesday, December 1, 2020

Q6-Q10

Q6. Can we return view using REST webAPI?
Q7. Can we add route at run time in WEB API?
Q8. What is AntiForgery token?
Q9. How to change the name of route in webapi? Custom method names in webapi. 
Q10. How you do authentication in webapi?
-------------------------------------------------------------------------------------------------------------------------
Q6. Can we return view using REST webAPI?

Answer:
Simple answer is no. WebApi controllers returns just data. Its the MVC controller that returns View.
-------------------------------------------------------------------------------------------------------------------------
Q7. Can we add route at run time in WEB API?

Answer:
Yes. you can do by calling Configuration.Initializer(Configuration) and making changes in CustomHttpControllerSelector  class.
-------------------------------------------------------------------------------------------------------------------------
Q8. What is AntiForgery token?

Answer:
AntiForgery Token is used to avoid CSRF. Cross-Site Request Forgery (CSRF) is an attack where a malicious site sends a request to a vulnerable site where the user is currently logged in. 
-------------------------------------------------------------------------------------------------------------------------
Q9. How to change the name of route in webapi? Custom method names in webapi. 

Answer:
Change in name of route can be done at 3 level
1. global level, 
2. Controller level
  1. [RoutePrefix(“reviews”)]
3. Action level
  1. Attribute routing - [Route("api/student/names")] 
  2. Action name - [ActionName("GetEmployeeByID")] 
-------------------------------------------------------------------------------------------------------------------------
Q10. How you do authentication in webapi?

Answer:

No comments:

Post a Comment