本文介绍了不在ASP核心web api中输入HTTPPOST操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i create aweb service in asp core2.2 and send data from client (angular6).

my controller in Admin area .

this Startup :







<pre lang="c#">
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseSignalR(routes =>
        {
            routes.MapHub<CrudRealTime>("/CrudRealTime");
        });
        app.UseCors("CorsPolicy");
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "areas",
                template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
            );
        });
    }







i use this address for access Create Roles Actoin in RoleManager Controller :

https://localhost:44390/api/role/createrole

but it not enter in action . when i use this role it work : https://localhost:44390/api/role/GetRoles but i dont know whats the problem and how can i solve this .

last time i run the project and it givee data from Client but now it not work . i did not change any things in server code .

how can i solve this problem ????










i create aweb service in asp core2.2 and send data from client (angular6).

my controller in Admin area .

this Startup :

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseSignalR(routes =>
        {
            routes.MapHub<CrudRealTime>("/CrudRealTime");
        });
        app.UseCors("CorsPolicy");
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "areas",
                template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
            );
        });
    }
i use this address for access Create Roles Actoin in RoleManager Controller :

https://localhost:44390/api/role/createrole

but it not enter in action . when i use this role it work : https://localhost:44390/api/role/GetRoles but i dont know whats the problem and how can i solve this .

last time i run the project and it givee data from Client but now it not work . i did not change any things in server code .

how can i solve this problem ????

RoleAction

What I have tried:

<pre>[HttpPost("CreateRole")]
    public async Task<IActionResult> CreateRole([FromBody]RolePostModel model)
    {
        if (ModelState.IsValid)
        {

            var result = await _roleManag.CreateAsync(new Role(model.description, model.rolelevel, model.name));
            if (result.Succeeded)
            {
                return Ok(Messagesresx.Success_Add_Role);
            }
            else
            {
                return Content(Messagesresx.Fail_Add_Role_In_DataBase);
            }
        }
        else
        {
            return BadRequest();
        }
    }

推荐答案


这篇关于不在ASP核心web api中输入HTTPPOST操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 05:23