Quantcast
Channel: ASP.NET Core
Viewing all 9386 articles
Browse latest View live

Upgrade users to new version in batches, without interuption and using the same URL

$
0
0

Greetings,

I am developing an application where users can login and get some work done, eventually the plan is to release a new version every month with new features and bug fixes

I am looking for the best way to upgrade users gradually in batches, without interruption and using the same URL

I assume I need to release the new version to a new directory and write some code to redirect users to their corresponding version after they login

Example

When User1 login, he is redirected to http://www.mysite.com/dashboard and user1 sees the dashboard deployed in the c:\inetpub\january version

When User2 Login, he is redirected to the same URL http://mysite.com/dashboard but User2 sees the version deployed in the c:\inetpub\february version

Any resources on how to achieve that? Is there a better way to get the job done?


viewbag gives nullreference exception for dropdownlist

$
0
0

In controller for create method-

public IActionResult Create()
{
PopulateAppUserDropDownList();
return View();
}
private void PopulateAppUserDropDownList(object selectedUser = null)
{  var appuserQuery = (from u in _context.Users
join ur in _context.UserRoles on u.Id equals ur.UserId
join r in _context.Roles on ur.RoleId equals r.Id
where r.Name == "Manager"
select u).AsNoTracking();

ViewBag.UserId = new SelectList(appuserQuery.AsNoTracking(), "UserId", "Email", selectedUser);
}

in cretae.cshtml

<div class="form-group">
<label asp-for="AppUser" class="control-label"></label>
<select asp-for="UserId" class="form-control" asp-items="ViewBag.UserId ">
<option value="">-- Select Department --</option>
</select>
<span asp-validation-for="UserId" class="text-danger" />
</div>

problem with cache middleware

$
0
0

Hi there,

As you know, in previous version of asp.net, we could cache the result of an action using OutputCache attribute. However, in asp.net core, mvc and OutputCache are separate middle-wares. Do you have any ideas for how to execute a code before caching?

Thanks in advance

Client validation with viewmodels

$
0
0

If i use a viewmodel like the sample apps do, i lose client validation. I can repeat the validation attributes in the viewmodel, but that would break the DRY principle. I wonder if there is a better way.

EF MVC Core 2.1 One-to-Many dropdown. Code-first.

$
0
0

Hi, all,

I am familiar with EF6; however, pretty new to Core 2.1.

I am writing an app in Core 2.1. I have two domain classes. One-to-many relationship in code-first.

What I am having trouble with is that when I scaffold, a drop down list is not being generated in the controller or even in the views. Does this have to be done in a different way in Core 2.1?

As an example. One vendor to multiple items. Meaning the items screen should have a drop down for a vendor the item belongs to.

I have searched online for almost two weeks now and haven't found anything on it.

How do I pass model from view to controller?

$
0
0

Hello,

I have an Asp.Net Core 2.1, MVC, C# Web application in Visual Studio 2017 15.7.5.

I am using this to create a link on the screen:

@model List<ChinavasionAPI.Models.CAPIViewModels.ProductViewModel>
@{
ViewData["Title"] = "products";
}<h2>Products List</h2><div class="container-fluid"><div class="row"><div class="col-md-5"></div><div class="col-md-2">
            @Html.ActionLink("Delete Products", "DeleteProducts", "Products", @Model)</div><div class="col-md-5"></div></div></div>

so that this method is called:

public ActionResult DeleteProducts(List<ProductViewModel> myModel)
  {
       return View("~/Views/API/AccessToken.cshtml", myModel);
  }

But, when it gets to the method, the myModel is empty.

How do I pass the model to the controller?

Thanks,
Tony

How to increment table row in ascending order

$
0
0

I have added tr on button click event I get total length of tr in index variable  and add 1 to it, its perfect for rows but I set the Ids of element in td according to index so if I add three rows the Id of last td's element is "createstepsVM[2]" because index is 2 if I remove tr 0 and 1 and then I add tr its index is 2 same as previous tr so both tr have same Ids which is wrong how do I get disticnt Id

here is my jquery code

 document.addEventListener('DOMContentLoaded', function () {
        document.getElementById("btnCreateSteps").addEventListener("click", function () {
            //$('.userList').empty();
           // $('.userList1').empty();
            var index = $("#tbSteps").children("tr").length+1;
            var indexCell = "<td style='display:none'><input name='CreateStepsVM.Index' type='hidden' value='" + index + "' /></td>";
            var imagecell1 = "<td><span class='arrow'><img src='/images/arrow-right.png'></span> </td>";
            var stepcell = "<td><span class='step-no'>Step <sup>" + index + "</sup> </span></td>";
            var labelcell = "<td><span class='label-dept' ><input type='text' name='CreateStepsVM[" + index + "].label' id='steplabel" + index + "' placeholder='Dept' class='dept-role'></span> </td>";
            var imagecell2 = "<td><span class='arrow'><img src='/images/arrow-right.png'></span></td>";
            var imagecell3 = "<td><span class='arrow arrow-right'><img src='/images/arrow-right.png'></span></td>";
            var checkCell = " <td><div class='input-fancy'><input type='radio' name='CreateStepsVM[" + index + "].criteria' id='byuser" + index + "' onchange='myFunction(" + index + ")' value='1'><label for='byuser" + index + "'><span> By User </span> </label></div>" +"<div class='input-fancy'><input type='radio' name='CreateStepsVM[" + index + "].criteria' id='byrole" + index + "' onchange='myFunction(" + index + ")' value='2'> <label for='byrole" + index + "'> <span> By Role </span></label></div>" +" <div class='input-fancy'> <input type='radio' name='CreateStepsVM[" + index + "].criteria' id='bydept" + index + "' onchange='myFunction(" + index + ")' value='3'><label for='bydept" + index + "'> <span> By Dept </span></label> </div>" +"<div class='input-fancy'><input type='radio' name='CreateStepsVM[" + index + "].criteria' id='by-dept-role" + index + "' onchange='myFunction(" + index + ")' value='4'> <label for='by-dept-role" + index + "'><span> By Dept / Role </span></label></div></td>";
            var dropdowncell = "<td><div class='selector-wrapper'><select class='userList" + index + "' name=''  id= 'CreateStepsVM" + index + "__abc'></select></div></td>";

            var removeCell = "<td><div class='action-wrapper'><div class='action-delete'><button class='btn btn-danger' type='button' onclick='removeRow(" + index + ")';><span class='icon'> <i class='fa fa-trash-o' aria-hidden='true'></i></span></button></div></div></td>";

            var newRow = "<tr id='trSteps" + index + "'>" + indexCell + stepcell + imagecell1 + labelcell + imagecell2 + checkCell + imagecell3 + dropdowncell + removeCell + "</tr>";$("#tbSteps").append(newRow);
        }, false);
    });

        function removeRow(id) {
            var controlToBeRemoved = "#trSteps" + id;$(controlToBeRemoved).remove();

    }

Razor Page app w/Virtual Directory

$
0
0

So I'm just starting out using Razor pages and so far I'm loving it.  That said, I have come upon an issue that I'm not sure how address.

I've created a very basic site on my IIS (Windows Server 2012 R2) that displays a listing of PDF files.  

the base URL is something like http://testing.lyonsmagnus.com

I can navigate to the images by appending the path to the base URL (http://testing.lyonsmagnus.com/labels/labelname.pdf)

This works fine until I deploy my Razor app into the directory.  After deployment of the app if I try to manually navigate to the same URL as above I receive a 404 error.  I've been pulling out quite a bit of hair trying to figure out why IIS wasn't recognizing the URL as valid.  I notice that if I delete the Razor app from the site, I can once again navigate to the URLs.

It seems that I'm missing something.  Is there something that needs to be configured in the Razor app (I'm using VS 2017) in order to account for a virtual directory?  I feel like I'm missing a basic piece here and I just can't find out what it is.

Any suggestions are much appreciated.


Check if foreign ID still exits - how to approach

$
0
0

Hello,

So I have a project where i for an example have this class

        public int SupportTeamID { get; set; }
        [Required]
        public int ContactInformationID { get; set; }
        [Required]
        public string SupportTeamName { get; set; }

        public IEnumerable<ContactInformation> ContactInformations { get; set; }
         public IEnumerable<SupportTeam> SupportTeams { get; set; }

    }
}

As you can see it uses the ID of two other entities.

But as it is now in my view, I can set it to an existing ContactInformationID, then delete that ContactInformationIDin the ContactInformation view  and now the Supportteam has an ID to a non existing ContactinformationID. 

I'm not sure what the general approach to this is, can anyone provide me some guidance?

Thanks in advance.

Bootstrap modal doesn't close on a valid model save

$
0
0

Hi all,

I use a bootstrap modal to enter some infos and save it, if my model isn't valid, the partial view is return with validation errors but if everything is fine and the model is valid, the modal stays open even if I return the complete view. How can I close the modal after saving?

Controller:

public IActionResult CompleteReg(UserViewModel model)
        {

            if (ModelState.IsValid)
            {
                
                return RedirectToAction("UserHome");
            }
            else
            {
                return PartialView("_ConfirmReg",model);
            }

          
        }

Here's part of the main view:

<div class="container HQAppMain">


    @if (SignInManager.IsSignedIn(User))
    {
        <div class="row"><div class="col-md-12"><div class="d-flex justify-content-center">
                    Statut: @Model.Statut.ToString()</div></div></div><div class="row"><div class="col-md-12"><div class="d-flex justify-content-center">
                    @if (Model.Statut == Commun_PLSD.Models.Enums.StatutCompteLocal.Limite)
                    {<p class="border-top border-bottom" /><span class="HQIconPadding HQGreen fa fa-exclamation-circle fa-2x"></span><span>Complétez votre profil pour activer toutes les fonctionnalitées</span><span><a data-toggle="modal" data-target="#CompleteReg" class="HQIconPadding HQGreen fa fa-chevron-right fa-2x"></a></span><p />
                    }</div></div></div><div class="row"><div class="col-md-12"><div class="d-flex justify-content-center">
                    @Localizer["LBLHello"]  @Model.FullName</div></div></div>
        @if (Model.Statut == Commun_PLSD.Models.Enums.StatutCompteLocal.Complet)
        {<div class="row"><div class="col-md-12"><div class="d-flex justify-content-center"><svg id="donorBarCode"></svg></div></div></div>
        }
    }
    else
    {<div>
            Utilisateur non authentifié
        </div>

    }


</div><!-- Modal pour compléter son inscription -->


@await Html.PartialAsync("_ConfirmReg")



@section Scripts {
   @await Html.PartialAsync("_ValidationScriptsPartial")
}

The partial view containing the modal:

<form asp-action="CompleteReg" asp-controller="User" method="post" data-ajax="true" data-ajax-update="frmConfirm"><div class="modal fade" id="CompleteReg" tabindex="-1" role="dialog" aria-labelledby="CompleteReg" aria-hidden="true"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="exampleModalLabel">Complétez votre profil</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button></div><div class="modal-body" id="frmConfirm"><input type="hidden" asp-for="UserID" /><div class="form-group row"><label asp-for="DonorNumber" class="col-4 col-form-label"></label><div class="col-8"><input asp-for="DonorNumber" class="form-control" /><span asp-validation-for="DonorNumber" class="text-danger"></span></div></div><div class="form-group row"><label asp-for="BirthDate" class="col-4 col-form-label"></label><div class="col-8"><input asp-for="BirthDate" class="form-control" placeholder="jj-mm-yyyy" /><span asp-validation-for="BirthDate" class="text-danger"></span></div></div><div class="form-group row"><label asp-for="PostalCode" class="col-4 col-form-label"></label><div class="col-8"><input asp-for="PostalCode" class="form-control" placeholder="A9A 9A9" /><span asp-validation-for="PostalCode" class="text-danger"></span></div></div></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button><button type="submit" data-save="modal" class="btn btn-primary">Sauvegarder</button></div></div></div></div></form>




@section Scripts {
    @await Html.PartialAsync("_ValidationScriptsPartial")
}

And the model:

 public class UserViewModel
    {
        public List<Centre> Centers { get; set; }
        public string Name { get; set; }
        public string FirstName { get; set; }
        public string FullName
        {
            get
            {
                return FirstName + " " + Name;
            }
        }

        public bool OpenModal { get; set; }

        [Required(ErrorMessage ="Le {0} est obligatoire")]
        [StringLength(7, ErrorMessage = "Le {0} doit avoir au moins {2} et un maximun de {1} caractères.", MinimumLength = 2)]
        [Display(Name = "Numéro de donneur")]
        public string DonorNumber { get; set; }

        [Required(ErrorMessage = "Le {0} est obligatoire")]
        [DateFormatValidator(ErrorMessage = "Format de date non valide")]
        [Display(Name = "Date de naisance")]
        public string BirthDate { get; set; }

        [Required(ErrorMessage = "Le {0} est obligatoire")]
        [StringLength(7, ErrorMessage = "Le {0} doit être composé de 7 caractères.", MinimumLength = 7)]
        [Display(Name = "Code postal")]
        public string PostalCode { get; set; }

        public string UserID { get; set; }
        public StatutCompteLocal Statut { get; set; }

        public List<DisplayMessage> Messages { get; set; }

    }

Actual SignalR Documentation for ASP.NET Core?

$
0
0

Hi,

I am using SignalR within an ASP.NET Core 2.1 MVC application which works great in general, but I have some questions regarding Hub functionality. 

User / Connection Mapping:

The SignalR ASP.NET documentation seems to be outdated in this cases or I haven't found the related ASP.NET Core documentation yet.

https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/mapping-users-to-connections

The ConnectionMapping class in this example seems to not work anymore with ASP.NET Core, as in the Client.Send function now a readonly list is expected.

await Clients.Clients(_connections.GetConnections(Context.User.Identity.Name)).SendAsync("Result", jsonResult);

And what was or is the proper way to get the connection from the ConnectionMapping class, when I use

string name = Context.User.Identity.Name;

OnConnected, OnDisconneted, (Reconnect):

A OnReconnected function does not exist anymore in ASP.NET Core, is that right? What is the reason for that or what was the reason in ASP.NET for the OnReconnect function?

Thanks!

Using update panel dynamically

$
0
0

am using update panel dynamically to overcome post-back issue, it's work just one time when i selecting drop-down list value retain but when i select other dropdown again facing same issue post-back page is refreshing .

am sharing my code ..Please help me out  i try to search on internet many time but i didn't get any solution . please help me out this issue

Html Code:

<form id="form1" runat="server"><asp:DropDownList ID="node_type_list" runat="server" OnSelectedIndexChanged="node_type_list_SelectedIndexChanged"><asp:ListItem Value="Select">Select</asp:ListItem><asp:ListItem Value="2">Splitter 1:2</asp:ListItem><asp:ListItem Value="4">Splitter 1:4</asp:ListItem><asp:ListItem Value="8">Splitter 1:8</asp:ListItem><asp:ListItem Value="1">Joint</asp:ListItem><asp:ListItem Value="0">ONT</asp:ListItem></asp:DropDownList><asp:Button ID="btn" runat="server" Text="Submit" OnClick="btn_Click" /></form>

code Behind :

protected void UpdatePanel_Unload(object sender, EventArgs e)
    {
        MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
            .Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First();
        methodInfo.Invoke(ScriptManager.GetCurrent(Page),
            new object[] { sender as UpdatePanel });
    }


    protected void btn_Click(object sender, EventArgs e)
    {
        UpdatePanel u1 = new UpdatePanel();
        u1.Unload += new EventHandler(UpdatePanel_Unload);
        u1.ChildrenAsTriggers = false;
        u1.UpdateMode = UpdatePanelUpdateMode.Conditional;
        int index = Convert.ToInt32(node_type_list.SelectedValue);
        for (int i = 0; i < index; i++)
        {

            DropDownList drop1 = new DropDownList();


            drop1.SelectedIndexChanged += new EventHandler(dro_SelectedIndexChanged);
            drop1.ID = "nxt_nod_typs" + i;
            drop1.Items.Add(new ListItem("Select Splitter", "0"));
            drop1.Items.Add(new ListItem("Splitter1:2", "2"));
            drop1.Items.Add(new ListItem("Splitter1:5", "5"));
            drop1.Items.Add(new ListItem("Splitter1:8", "8"));
            drop1.Items.Add(new ListItem("Joint", "1"));
            drop1.Items.Add(new ListItem("ONT", "0"));
            drop1.AutoPostBack = true;
            drop1.SelectedIndexChanged += new EventHandler(dro_SelectedIndexChanged);

            div1.Controls.Add(drop1);

            //  this.div1.Controls.Add(u1);
            //UpdatePanel u2 = new UpdatePanel();
            //u2.Unload += new EventHandler(UpdatePanel_Unload1);
            DropDownList drop = new DropDownList();

            drop.SelectedIndexChanged += new EventHandler(dro_SelectedIndexChanged);
            drop.ID = "nxt_nod_typ" + i;
            drop.Items.Add(new ListItem("Select Splitter", "0"));
            drop.Items.Add(new ListItem("Splitter1:2", "2"));
            drop.Items.Add(new ListItem("Splitter1:5", "5"));
            drop.Items.Add(new ListItem("Splitter1:8", "8"));
            drop.Items.Add(new ListItem("Joint", "1"));
            drop.Items.Add(new ListItem("ONT", "0"));
            drop.AutoPostBack = true;
            drop.SelectedIndexChanged += new EventHandler(dro_SelectedIndexChanged);

            div1.Controls.Add(drop);
            u1.ContentTemplateContainer.Controls.Add(drop1);
            u1.ContentTemplateContainer.Controls.Add(drop);
            AsyncPostBackTrigger trig = new AsyncPostBackTrigger();

            trig.ControlID = drop.ID;
            trig.ControlID = drop1.ID;
            trig.EventName = "SelectedIndexChanged";
            u1.Triggers.Add(trig);
            this.div1.Controls.Add(u1);
            this.div1.Controls.Add(new LiteralControl("<br/>"));
            this.div1.Controls.Add(new LiteralControl("<br/>"));


            //this.Page.Form.Controls.Add(new LiteralControl("/t"));

        }
        Button clk = new Button();
        clk.ID = "probtn";
        clk.Text = "Process";
        clk.CssClass = "mysubmit";
        clk.Click += new System.EventHandler(Submit);
        div1.Controls.Add(clk);
        u1.ContentTemplateContainer.Controls.Add(clk);
        AsyncPostBackTrigger trigs = new AsyncPostBackTrigger();
        trigs.ControlID = clk.ID;
        u1.Triggers.Add(trigs);
        this.div1.Controls.Add(u1);
        this.div1.Controls.Add(new LiteralControl("<br/>"));
    }
    int count;
    static int rows = 0;
    void dro_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label lb = new Label();
        lb.Text = ((DropDownList)sender).SelectedValue;
        count = Convert.ToInt32(lb.Text);
        if (Session["drocount"] != null)
        {
            rows = Convert.ToInt32(Session["drocount"]) + Convert.ToInt32(((DropDownList)sender).SelectedValue);
            Session["drocount"] = rows;
        }
        else
        {
            rows = Convert.ToInt32(((DropDownList)sender).SelectedValue);
            Session["drocount"] = rows;
        }
        lb.Text = Session["drocount"].ToString(); ;


    }

Logging to SQL Server

$
0
0

I've been looking into logging to SQL server from my ASP.NET Core web API. There are several logging providers. Having looked at a few of them I have decided to use NLog. Mainly because I found various (almost) tutorials on doing just that from an ASP.NET Core application. The main thing I suffer with is being new to ASP.NET Core and then trying to read "tutorials". Reading the website when NLog is from it offers some help but the main problem I tend to face is that there is simply too much choice in terms of what I want to do and I can't seem to find the right solution.

I found this site: https://hk.saowen.com/a/ad3a706c5fac34fe7d2b24b6b11277c8dd1706c43bfdf8d61e44c9d6aaa59a82

Which seems to show exactly what I want. The first problem I hit is when I get to configuring the stored procedure parameters. I need different ones but then it doesn't explain what the layouts mean. Dipping back onto the NLog github page, I looked for layouts and the page https://github.com/NLog/NLog/wiki/Layouts and it explains how they're used and does not clearly explain what they are. So, If I use a layout, what does it do? An example?

With the logging, all I need is to be able to pass to the logging provider a bunch of parameters and it dump them in a table. They're just text that I shall write in the code. Do I need layouts? Going back to the tutorial it move onto the publishOptions.json. This doesn't exist in my project, so why not? If I create it, where do I put it? It suggests it should be there. What if it isn't?

Creating the db and stored procedure is easy. Once it is there it looks like I add it to the Startup class and then use DI within the application to log data. But I can't seem to get that far, and that seems to be the story of my life with following tutorials.

Any help would be appreciated.

How to merge IdentityDbContext and MyDbContext that aspnet-codegenerator generates?

$
0
0

Hey guys.

I am using aspnet-codegenerator cli to generate identity and aspnet-codegenerator controller like this:

dotnet aspnet-codegenerator controller -name MoviesController -m Movie -dc MoviesDbContext --relativeFolderPath Controllers --useDefaultLayout

and

dotnet aspnet-codegenerator identity --dbcontext MovieIdentityDbContext --userClass User --useDefaultUI

As you know these commands generate two DbContext one in Areas/Identity/Data and one in Data/ and also one connectionString in appsettings.json for each dbContexts.

I am confused how database should create!? do i have two databases? How about if i want to have just one dbContext?

When i dont use codegenerator I have one dbContext that inherits from IdentityDbContext and it's fine but i should create all Views,Controllers and Codes.

Starting a WebAPI-WebApp application

$
0
0

Hi,

I am trying to start my WebAPI-WebApp application and as soon as it goes through the Program.cs and Startup.cs of the WebApp, it exits the code.  Show output from debug shows

I used ASP.Net Core Web Application version 2.1

The program '[8968] dotnet.exe' has exited with code -1 (0xffffffff)

Program.cs

    public class Program
    {

        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                //.UseApplicationInsights()
                .Build();

            host.Run();
        }
    }

Startup.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Person_WebAPI.Client;

namespace Person_WebApp.WebApp
{
    public class Startup
    {

        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.Development.json", optional: true, reloadOnChange: true)
                //.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables();

            Configuration = builder.Build();
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();
            //app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}

appsettings.json
{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "ConnectionStrings": {
    "DefaultConnection": "data source=devsql2016;initial catalog=PartyAPI;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
  },
  "WebApiUrl": {
    "DefaultUrl": "http://localhost:57705/"
  }
}

Please advise.

Thanks,

tinac99


HTTP Error 502.5 Process Failure with IIS

$
0
0

Hello,

I am trying to set up a new version of my application on a server but when I try to access to the web site, I get a HTTP error (502.5 - Process Failure).

The service is started and when I check the connection, I don't have any warning.

Connection Tests

The stdoutlog :

Expression: [Recursive resource lookup bug]
Description: Infinite recursion during resource lookup within System.Private.CoreLib.  This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names.  Resource name: ArgumentNull_Generic

If I try the dotnet cmd to launch the exe :

>dotnet Maquetteur.Web.exe
Failed to load the dll from [C:\temp\MaquetteurWinServer2012_new\hostpolicy.dll], HRESULT: 0x7BF030
An error occurred while loading required library hostpolicy.dll from [C:\temp\MaquetteurWinServer2012_new\]

Server Event viewer :

Application 'MACHINE/WEBROOT/APPHOST/OPTIMOBEE' with physical root 'C:\temp\MaquetteurWinServer2012_new\' created process with commandline 'C:\temp\MaquetteurWinServer2012_new\Maquetteur.Web.exe ' but failed to listen on the given port '15731

In my csproj :

<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>netcoreapp2.0</TargetFramework><UserSecretsId>3a51662b-79e6-4d37-be0c-c1e406dae19c</UserSecretsId><RuntimeIdentifiers>win7-x64;linux-x64;win8-x64</RuntimeIdentifiers><Version>0.2.0</Version></PropertyGroup><ItemGroup><PackageReference Include="AutoMapper" Version="6.2.2" /><PackageReference Include="CoreCompat.System.Drawing" Version="1.0.0-beta006" /><PackageReference Include="jQuery.filedrop" Version="1.0.1" /><PackageReference Include="jQuery.UI" Version="1.12.1.1" /><PackageReference Include="jQuery.UI.Combined" Version="1.12.1" /><PackageReference Include="jQWidgets.AspNetCore.Mvc.TagHelpers" Version="2.0.1" /><PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.3.0" /><PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /><PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" /><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" /><PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" /><PackageReference Include="MySql.Data" Version="8.0.11" /><PackageReference Include="NLog.Web.AspNetCore" Version="4.5.4" /><PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" /><PackageReference Include="NSwag.Core" Version="11.17.17" /><PackageReference Include="SoapCore" Version="0.9.7" /><PackageReference Include="Swashbuckle.AspNetCore" Version="2.5.0" /><PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="2.5.0" /><PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="2.5.0" /><PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="2.5.0" /><PackageReference Include="ZXing.Net" Version="0.16.4" /></ItemGroup><ItemGroup><DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /><DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /></ItemGroup><ItemGroup><Content Update="nlog.config"><CopyToOutputDirectory>Always</CopyToOutputDirectory></Content></ItemGroup><ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions></Project>

And my publisher file :

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><WebPublishMethod>FileSystem</WebPublishMethod><PublishProvider>FileSystem</PublishProvider><LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration><LastUsedPlatform>Any CPU</LastUsedPlatform><SiteUrlToLaunchAfterPublish /><LaunchSiteAfterPublish>True</LaunchSiteAfterPublish><ExcludeApp_Data>False</ExcludeApp_Data><ProjectGuid>7a5caaf4-d505-435a-8215-a59e69b5fe5e</ProjectGuid><publishUrl>C:\temp\MaquetteurWinServer2012</publishUrl><DeleteExistingFiles>False</DeleteExistingFiles><TargetFramework>netcoreapp2.0</TargetFramework><RuntimeIdentifier>win8-x64</RuntimeIdentifier></PropertyGroup></Project>

I tried different ways to resolve my problem withou success... I can launch it in Debug and Release mode in visual studio.

I think it is a problem with Identity Core because I added it in this new version. Before Identity, I didn't have any problem to set up a new version on my server.

The specs :

Dev
- Visual Studio Community 2017 v15.7.5
- EF Core 2.0.0

Server
- Windows Server 2012 R2

I have maybe missed some information.

Have you an idea why I have this error ?

How to use currency symbol left or right side ?

$
0
0

Hi, 

Some currency symbol is left side some currency is right side. Example $ 100.00 for dolar or USD 100.00, other example is about Turkish Liras100,00 TL or 100,00 ₺. You can see what you mean in https://sale.aliexpress.com/ if you change currency... 

how to do it ? 

How I upload the project on server.

$
0
0

I want to upload project on server but I don't know asp.net.  In the project, I have ee.core, ee.api, ee.data, eee,ui and ee.admin projects. 

How I publish these all together?

IIS hosting ASP.NET Core application not pass query string to kestrel server

$
0
0

As title,I create an asp.net core app,i have one page need to get query string by name(Request.Query["a"]),when I test in visual studio 2017,it runs ok! But when I publish to IIS(window server 2016), it run like ok. But i can't get query string.But if I use localhost to visit site.It can get query string.but if visit this app by special domain, I can't get query string,I try to see .net core logs, It like iis not pass query string to kestrel when I user special domain? what's wrong about this?

Environment:
Windows server 2016
.NET Core Runtime 2.1.2

some log file:

Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost/vwzao/?a=b
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[1]
Route matched with {page = "/Index"}. Executing action /Index
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[101]
Executing handler method OnGet with arguments (b) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[2]
Executed action /Index in 98.6913ms

special domain log:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 2004.1323ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://st.XXXXXXX.com/vwzao/
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[1]
Route matched with {page = "/Index"}. Executing action /Index
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[101]
Executing handler method OnGet with arguments () - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[2]
Executed action /Index in 3.594ms

razor page creation via scaffolding

$
0
0

Is there a way to prevent the edit page from being generated when scaffolding pages?  Is there a way to no include all the fields (columns) from the context in the index page when scaffolding?

Viewing all 9386 articles
Browse latest View live