Base solution for your next web application

Activities of "oaalvarado"

Hi @ismcagdas,

Sorry for the late response, I was out of the office last week. I enabled the Preserve log in Dev Tools and tried to Save a new port. At first I had a javascript error, the script file was not loading. I fixed this, and now I get this error in the Dev Tool Console:

POST http://localhost:62114/api/services/app/Ports/Create 415 (Unsupported Media Type)

Thanks for your help.

Hi maliming,

This is the code for the Create method in portsAppService:

    [AbpAuthorize(AppPermissions.Pages_Ports_Create)]        
    public async Task Create(CreatePortDto input)
    {
        var organization = new Organization()
        {
            Name = input.Name,
            Logo =  null, //input.Logo,
            Address = input.Address,
            Phone1 = input.Phone1,
            Phone2 = input.Phone2,
            Fax = input.Fax,
            EMail1 = input.EMail1,
            EMail2 = input.EMail2,
            Website = input.Website,
            CategoryId =  input.CategoryId,
            CountryId = input.CountryId,
            CityId = input.CityId
        };

        var result = await _organizationRepository.InsertAsync(organization);

        var port = new PortDetail()
        {
            Code = input.Code,
            Governance = input.Governance,
            OrganizationId = result.Id
        };

        var result2 = await _portDetailRepository.InsertAsync(port);
    }
   

This is the output for abp.services.

I have noticed that when I click in the Save button, the code in the portsAppService is not called. Neither the code in the Javascript. I think maybe is something with the CSHTML? This is the Create.cshtml code (I removed part of the code that is irrelevant):

@using CPMS.Authorization @using CPMS.Web.Areas.App.Models.Ports @using CPMS.Web.Areas.App.Startup

@model CreatePortViewModel @{ ViewBag.CurrentPageName = AppPageNames.Application.Ports; }

@section Scripts { <script abp-src="/view-resources/Areas/App/Views/Ports/Create.js" asp-append-version="true"></script> }

**&lt;form class=&quot;kt-form createPort-form&quot; id=&quot;CreatePortForm&quot; name=&quot;CreatePortForm&quot; role=&quot;form&quot; novalidate asp-action=&quot;Create&quot; asp-controller=&quot;Ports&quot; asp-area=&quot;App&quot; method=&quot;post&quot;&gt;**
    &lt;div class=&quot;kt-subheader kt-grid__item&quot;&gt;
        &lt;div class=&quot;kt-subheader__main&quot;&gt;
            &lt;h3 class=&quot;kt-subheader__title&quot;&gt;
                &lt;span&gt;@L("CreateNewPort")&lt;/span&gt;
            &lt;/h3&gt;
            &lt;span class=&quot;kt-subheader__separator kt-subheader__separator--v&quot;&gt;&lt;/span&gt;
            &lt;div class=&quot;kt-subheader__desc&quot;&gt;
                @*&lt;h3&gt; @Model.Code - @Model.Name &lt;/h3&gt;*@
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;kt-subheader__toolbar&quot;&gt;
            &lt;div class=&quot;kt-subheader__wrapper&quot;&gt;
                &lt;button id=&quot;ReturnPortList&quot; class=&quot;btn btn-primary&quot;&gt;&lt;i class=&quot;fa fa-backward&quot;&gt;&lt;/i&gt; @L("PortsList")&lt;/button&gt;
               ** &lt;button id=&quot;Save&quot; type=&quot;submit&quot; class=&quot;btn btn-secondary btn-outline-secondary&quot;&gt;&lt;i class=&quot;fa fa-save&quot;&gt;&lt;/i&gt; @L("Save")&lt;/button&gt;**
                &lt;button id=&quot;SaveAndEdit&quot; type=&quot;submit&quot; class=&quot;btn btn-secondary btn-outline-secondary&quot;&gt;&lt;i class=&quot;fa fa-save&quot;&gt;&lt;/i&gt; @L("SaveAndEdit")&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    

When I click the submit button, it goes to this URL: http://localhost:62114/api/services/app/Ports/Create but displays the error: HTTP Error 415.

Thanks for your help.

Hi exInt,

Thanks for the code. If I understand the code correctly, it is for a modal View. But I am not using a modal View, and want to use a normal View, because in the form I have to include several datatables, and this datatables will have modal Views to add or edit data.

Also, I don't know how to fix the "HTTP Error 415". How can I specify the Content Type in the submit? I believe the correct Content Type would be "application/JSON", right?

I'm still getting error HTTP Error 415:

This is the Header info from Developer Tool:

Hi,

Remove "Trusted_Connection=True;" from the connectionString, if you are not using Windows Authentication. Looks like you are using a SQL Server user to connect to the database.

I did some searching and I think the code in in the Login.cshtml, Login.js, EmailActivation.cshtml and EmailActivation.js files is what I need to do. I'm I right Maliming?

Hi,

Thanks exInt, I'll check the links you provided.

Maliming, the ContentType is 'application/x-www-form-urlencoded'.

I tried to do the call from javascript like this:

(function () { $(function () { var _portsAppService = abp.services.app.ports;

    var portForm = null;
           
    $('#Save').click(function () {
        portForm = $('#CreatePortForm').serializeFormToObject();
        
        _portsAppService.create({
            port: portForm
        }
        );
    })
            
});

})();

and I'm getting a Validation error message: "Your request is not valid!", which is correct, because I don't know how to call the validation from javascript. How can I call the validation from javascript for a View?

Thanks.

Thanks Maliming for your reply. I'll do what you suggested.

Hi maliming,

I tried to deploy to a website sub-application and I still get the errors. I'm guessing I need to update the href in layout.cshtml and login.cshtml to add the ~ so they can get the proper application path? Can you tell me which files I need to update the href?

Thanks.

Hi maliming,

I didn't know that ASP.NET Core does not support IIS Virtual Directory. I will try to deploy it to an IIS sub-application to see if it works. I'll let you know the results.

Thanks.

Showing 11 to 20 of 21 entries