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

problem with additional layout page

$
0
0

I would like to make a layout page based on the view shown below, with the content in the div with class "form-group" inserted in the resulting content pages. Or better yet, I'd like to make all the values after the "asp-for" and "asp-validation-for" tag helpers variable in each content page. Each content page would also have to contain a different model at the top. All this would help tremendously in my quest to make this a "DRY" project. Any hints?

PROPOSED LAYOUT PAGE:

@RenderBody()
@{await Html.RenderPartialAsync("_BeginAllPartial").ConfigureAwait(false); }<form asp-area=@ViewBag.Area asp-controller=@ViewBag.Controller asp-action=@ViewBag.Action asp-route-returnurl=@ViewData["ReturnUrl"] method="post" class="form-horizontal"><input type="hidden" asp-for="ID" />

    @{await Html.RenderPartialAsync("_FormBeginPartial").ConfigureAwait(false); }<div class="form-group"><div class="form-inline"><label asp-for=@RenderSection("ctrl01Label", required: true) class="control-label col-md-3"></label><input asp-for=@RenderSection("ctrl01Input", required: true) class="form-control col-md-offset-1 col-md-4" autofocus tabindex="10" /></div></div>


    @{await Html.RenderPartialAsync("_FormEndPartial").ConfigureAwait(false); }</form>

@{await Html.RenderPartialAsync("_EndAllPartial").ConfigureAwait(false); }


PROPOSED CONTENT PAGE:

@model InstructionalMaterialViewModel
@Layout="_CreateEditLayout"

@section ctrl01Label{"Isbn"}
@section ctrl01Input{"Isbn"}

Following is the error I get; I also find it strange that the term "section" didn't Intellisense for me.

An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.

/Features/Shared/Lookup/_CreateEditLayout.cshtml

An expression tree may not contain a named argument specification
<label asp-for=@RenderSection("ctrl01Label", required: true) class="control-label col-md-3"></label>
An expression tree may not contain a named argument specification
<input asp-for=@RenderSection("ctrl01Input", required: true) class="form-control col-md-offset-1 col-md-4" autofocus tabindex="10" />

Generated Code

An expression tree may not contain a dynamic operation
#pragma warning restore 199


I can not intercept the selected tab() with javascript ...

$
0
0

 Hello, I'm usingtabs in acshtmlpage ofasp.netmvc coreproject,but Ineed tofigure outwhichis activewith javascript.Ifollowed the directionsof somearticlesbut I can notfigure it out. Below the code html of the tab

<form id="myFormFix" asp-controller="controller-name" asp-action="action-name"><div class="container"><!--------><div id="content"><ul id="tabs" class="nav nav-tabs" data-tabs="tabs"><li class="active"><a href="#test1" data-toggle="tab">Test1</a></li><li><a href="#test2" data-toggle="tab">Test2</a></li><li><a href="#test3" data-toggle="tab">Test3</a></li><li><a href="#test4" data-toggle="tab">Test4</a></li><li><a href="#test5" data-toggle="tab">Test5</a></li><li><a href="#test6" data-toggle="tab">Test6</a></li></ul><div id="my-tab-content" class="tab-content"><div class="tab-pane active" id="test1">test1</div><div class="tab-pane active" id="test2">test2</div>
                                              .....<div class="tab-pane active" id="test6">test6</div></div></div></div></form>

How to pass variable server side to javascript? ..

$
0
0

helloeveryone, I'm developingwith VisualStudio2015asp.netmvccoreproject and I haveread several articlesbut nonecanexplainwell how topass an array ofobjects fromc#code(server side) tojavascript. That is I have a javascriptfunction thatworks fineby providingan array ofobjectsinitializedwithstatic values,but I want tocreate itdynamicallyretrieving datathrough querying adatabase. Below the javascript codewithstatic array:

<script>
        var Data=[
         {State:'AL',freq:{low:4786, mid:1319, high:249}}
        ,{State:'AZ',freq:{low:1101, mid:412, high:674}}
        ,{State:'CT',freq:{low:932, mid:2149, high:418}}
        ,{State:'DE',freq:{low:832, mid:1152, high:1862}}
        ,{State:'FL',freq:{low:4481, mid:3304, high:948}}
        ,{State:'GA',freq:{low:1619, mid:167, high:1063}}
        ,{State:'IA',freq:{low:1819, mid:247, high:1203}}
        ,{State:'IL',freq:{low:4498, mid:3852, high:942}}
        ,{State:'IN',freq:{low:797, mid:1849, high:1534}}
        ,{State:'KS',freq:{low:162, mid:379, high:471}}
        ];

        graphic('#graphic', Data);
</script>


Instead of the listof valuesI would like toassociate with"Date"an array of objectsfrom thecontroller. The script isinsertedinto a pagecshtml.

How to Log last Active Database Connection in ASP.NET Core

$
0
0

Hi, I am new to ASP.NET core and building an application. we got a requirement where we need to log the last active database connection and use it next time to reduce the likelihood of one connection attempt timing out. Please let me know how can I do this with logging the active database connection.

Please let me know if there are some configuration changes can be done to achieve the required output without using log database connection.

How to retrieve data of nested class instance from parent class instance in ASP.NET Core?

$
0
0

I am trying to modeling a class at school, and I end up with something like this:

public class Class
{
    public int ID { get; set; }
    public int Grade { get; set; }
    public Teacher ClassTeacher { get; set; }
}

This is the Teacher class:

public class Teacher
{
    public int ID { get; set; }

    [Display(Name = "First Name")]
    public string FirstName { get; set; }

    [Display(Name = "Last Name")]
    public string LastName { get; set; }

    [DataType(DataType.Date)]
    public DateTime Birthday { get; set; }
}

When I use scaffolding, migrate and update the database, this is the structure Entity Framework built for me:

dbo.Class:
ID: int
ClassTeacherID: int
Grade: int

dbo.Teacher:
ID: int
Birthday: datetime2(7)
FirstName: nvarchar(MAX)
LastName: nvarchar(MAX)

I want to display the Teacher's FirstName in Views\Classes\Details.cshtml, but the Model.ClassTeacher is null, even after I created a Teacher instance in the database and set ClassTeacherID to the newly created Teacher's ID. Looking for your helps.

Hangfire Implementation with MVC Asp.net core

$
0
0

Hi,

I have a requirement that implementing the hangfire dashboard inside my application itself.I have a link "Dashboard" in my home page clicking on that Hangfire dashboard should open as the part of my application.

The below code i tried

On click of Dashboard link

public void BuildNavigation(string name, NavigationBuilder builder)
        {
            if (!String.Equals(name, "menu", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            builder
                   .Add(T["Dashboard"], "1", installed => installed.Action("Index", "HangfireDashboard", "Modules.HangfireDashboard"));
        }


Startup.cs

publicclassStartup:StartupBase{publicvoidConfigure(IApplicationBuilder app,IHostingEnvironment env,ILoggerFactory loggerFactory,IServiceProvider serviceProvider){

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

        app.UseHangfireServer(options:newBackgroundJobServerOptions(){Activator=newJobActivator()});
        app.UseHangfireDashboard("/TestPage");}publicoverridevoidConfigureServices(IServiceCollection services){
        services.AddHangfire(configuration => configuration.UseSqlServerStorage(TenenatDbConfigurationProvider.GetDefaultConnectionString()));
        services.AddScoped<INavigationProvider,ModulesMenu>();}}

this is opening the index page of the modules not the hangfire dash board.

let me know if anybody have implemented this inside your modules

Thanks

Dev

How to write a web app with organisation authentication for power bi?

$
0
0

Hi, I'm a complete noob at .net core so please be kind :)

I'm trying to write an web API for powerbi to use. Everything works good exept for the powerbi part.

I'm using Azure AD to authenticate the user to the app. I added a new API controller and added [Authorize] to it. The user experience is perfect, when i call the API i get redirected to Microsoft for authentication and after i login I get the data as expected. 

Now I want to use my organisation account to call the API from PowerBI. When adding a web source from powerbi there is an authentication option called "Oraganizational account". But when i click login i get "We were unable to connect because this credential type isn't supported for this resource." it's like powerbi is't even trying. Anyone knows how to do this right. plz point me in the right direction :)

install .net core sdk on centos 7.2


Consume wcf service from asp.net core Credentials not found

$
0
0

I have added a service reference with Visual studio WCF connected service.

When i try to consume i receive the exception that the credentials are not found.

I´ve been able to consume this service in asp.net mvc but to make this work i made a trick to overriding the headers in the request:

 

 public class AgendasWs2 : CatalogosAgendasWS_A
    {
        protected override System.Net.WebRequest GetWebRequest(Uri uri)
        {

            HttpWebRequest request;
            request = (HttpWebRequest)base.GetWebRequest(uri);

            if (PreAuthenticate)
            {
                NetworkCredential networkCredentials = Credentials.GetCredential(uri, "Basic");
                if (networkCredentials != null)
                {

                    byte[] credentialBuffer = new UTF8Encoding().GetBytes(networkCredentials.UserName + ":" + networkCredentials.Password);

                    request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);
                }
                else
                {
                    throw new ApplicationException("No network credentials");
                }
            }
            return request;
        }
    }

As you can see i override the headers before sendind the request.

The service has a Preemptive authentication type

I dont have any idea of making this in asp.net core.

Any help :)

Problem with generate DateTime with Entity Framework

$
0
0

I am trying to model a chat box, therefore I want the time a Message created is generated by the database. This is myMessage class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DatabaseGenerated.Models
{
    public class Message
    {
        public int ID { get; set; }

        [Required]
        public string Content { get; set; }

        [Required]
        [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public DateTime CreatedTime { get; set; }
    }
}

After I use Visual Studio to scaffolding the controller and update the database, I tried toCreate a Message. However, I received an error:

SqlException: Cannot insert the value NULL into column 'CreatedTime', table 'DatabaseGeneratedContext-GUID.dbo.Message'; column does not allow nulls. INSERT fails.

I guess the problem is the database cannot generated the current time, so it insertNULL value. 

Please suggest me a solution for this. Thank you.

How to specify Custom Build Step in ASP.NET Core .csproj file?

$
0
0

(My first attempt at posting this seemed to simply fizzle with an error from the site, so all apologies if this is a duplicate.)

I have an ASP.NET Core project in Visual Studio 2017 and I need to add a custom pre-build step to copy the client files from the adjacent client project. The thing I am trying would at least be invoked by older ASP.NET MVC projects:

<Target Name="BeforeBuild"><Message Text="Copying Client Files..."/><Copy SourceFiles="..\MyProjectClient\**.*" DestinationFolder="wwwroot" OverwriteReadOnlyFiles="true" /></Target>

Looking at a Verbosity=Normal build of this project, the BeforeBuild target is never invoked, and I can't see any targets listed in what is invoked that look like good candidates. (I will probably have to fiddle a little with the SourceFiles and DestinationFolder paths to make the step actually work as intended, but I can only do that once the target is invoked.)

In the ASP.NET Core CSPROJ build scheme, what targets should I be using to intercept the build at various points? Is there anything I need to do to inform the build that I need specific targets included?

Trying to port WebApi (ApiController based) code to .Net Core

$
0
0

It seemed like the answer to all my problems was Microsoft.AspNet.Mvc.WebApiCompatShimbut when I try to install it it says  Webapi.Client 5.2.2 is not compatible with net core app1.1.

I am having so many problems trying to get around this.. any tips?

Just using [Controller] there are so many ApiController pieces of functionality missing that it seems impossible to build a webapi project!!

Trying to run a .net core application - error

$
0
0

Error on startup - the project system has encountered an error   -- value cannot be null -- Parameter name key  

diagnostic log is as follows..  grateful for any help provided - thanks

=====================
3/29/2017 12:43:12 PM
Crippling
System.AggregateException: One or more errors occurred. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.GetAllResolvedReferences()
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.ResolveReferences(String[] originalNames, AssemblyName[] assemblyName, VsResolvedAssemblyPath[] assemblyPaths)
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.ResolveAssemblyPathInTargetFx(String[] prgAssemblySpecs, UInt32 cAssembliesToResolve, VsResolvedAssemblyPath[] prgResolvedAssemblyPaths, UInt32& pcResolvedAssemblyPaths)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.ResolveAssemblyPath(String assemblySpec)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.ResolveAssembly(AssemblyName assemblyName)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetSystemAssembly()
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)
at Microsoft.VisualStudio.ProjectUtilities.GetTargetFrameworkProvider(IServiceProvider provider, IDesignTimeAssemblyLoader assemblyLoader, IVsHierarchy hierarchy, Object instance)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.get_TypeProvider()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.VSLangProj._dispReferencesEvents.ReferenceAdded(Reference r)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.OnReferenceAdded(Reference reference)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ReferencesHostBridge.ApplyAsync(ReferencesDelta value)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge`3.<>c__DisplayClass36_1.<<InitializeCoreAsync>b__3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask`1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge`3.<>c__DisplayClass36_0.<<InitializeCoreAsync>b__2>d.MoveNext()
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.GetAllResolvedReferences()
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.ResolveReferences(String[] originalNames, AssemblyName[] assemblyName, VsResolvedAssemblyPath[] assemblyPaths)
at Microsoft.VisualStudio.ProjectSystem.VS.References.DesignTimeAssemblyResolution.ResolveAssemblyPathInTargetFx(String[] prgAssemblySpecs, UInt32 cAssembliesToResolve, VsResolvedAssemblyPath[] prgResolvedAssemblyPaths, UInt32& pcResolvedAssemblyPaths)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.ResolveAssemblyPath(String assemblySpec)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.ResolveAssembly(AssemblyName assemblyName)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetSystemAssembly()
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)
at Microsoft.VisualStudio.ProjectUtilities.GetTargetFrameworkProvider(IServiceProvider provider, IDesignTimeAssemblyLoader assemblyLoader, IVsHierarchy hierarchy, Object instance)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.get_TypeProvider()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.VSLangProj._dispReferencesEvents.ReferenceAdded(Reference r)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.OnReferenceAdded(Reference reference)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ReferencesHostBridge.ApplyAsync(ReferencesDelta value)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge`3.<>c__DisplayClass36_1.<<InitializeCoreAsync>b__3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__76.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask`1.<JoinAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectHostBridge`3.<>c__DisplayClass36_0.<<InitializeCoreAsync>b__2>d.MoveNext()<---

Problems using WebResponse and WebRequest in asp.net core

$
0
0

Hello everyone, I can notoperatein asp.netmvc core the followingcode executedwithout problems in a desktop application:

var request = WebRequest.Create(requestUri);
var response = request.GetResponse();
var xdoc = XDocument.Load(response.GetResponseStream());

In ASP.NET MVC Core (using c #) does not recognize "GetResponse". How can I recoverproperly"xdoc"?

ArgumentException: The 'ClientId' option must be provided

$
0
0

Attempting to do 3rd party authentication using Facebook.  This used to work under .Net Core 1.0, but I just upgraded to VS2017 and .Net Core 1.1.

Complete error is:

ArgumentException: The 'ClientId' option must be provided.

Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<TOptions> options)

ArgumentException: The 'ClientId' option must be provided.

Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<TOptions> options)

Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<FacebookOptions> options)

Microsoft.Extensions.Internal.ActivatorUtilities+ConstructorMatcher.CreateInstance(IServiceProvider provider)

Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)

Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)

Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()

Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

I noted that .AddUserSecrets() deprecated so I updated to .AddUserSecrets<Startup>();

.csproj is as follows:

<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>netcoreapp1.1</TargetFramework><PreserveCompilationContext>true</PreserveCompilationContext><AssemblyName>SP_Reports</AssemblyName><OutputType>Exe</OutputType><PackageId>SP_Reports</PackageId><UserSecretsId>aspnet-SP_Reports-fe51af8e-b15e-40b8-a748-9260b3185259</UserSecretsId><PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback><RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion></PropertyGroup><ItemGroup><None Update="wwwroot\**\*;Views\**\*;Areas\**\Views"><CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory></None></ItemGroup><ItemGroup><ProjectReference Include="..\SP_Common_Classes\SP_Common_Classes.csproj" /></ItemGroup><ItemGroup><PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /><PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" /><PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" /><PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /></ItemGroup><Target Name="PrepublishScript" BeforeTargets="PrepareForPublish"><Exec Command="bower install" /><Exec Command="dotnet bundle" /></Target><ItemGroup><DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" /><DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" /></ItemGroup></Project>

Any suggestions??


Simple jQuery script doesnt fire

$
0
0

Hi!

I have this script on my page:

@section Scripts {$("#moreLink").click(function () {$(this).slideUp();$("#moreSection").show();
    });
}

this link

<a id="moreLink" href="#">Les mer</a>


and the section:

<section id="moreSection" style="display:none;">
    test</section>

  
    
So yeah, the idea is to click the link and the section appears. Pretty simple. But no. No matter what I do it doesnt appear.

If someone could please take a look at this and maybe look at the page source.
The page is located here: https://lundbeckconsulting.no/Home/About



Many thanks in advance :)

Can't communicate with ASP.NET Core webAPI from another computer.

$
0
0

Hello all, I'm new to ASP.NET and I'm having some trouble I'm hoping to get some help with. I've written a very simple ASP.NET Core WebAPI that I'm trying to test. When I run it on my development machine I am able to communicate with it via the browser by typing in: "http://localhost:8081/api/status". It returns the correct result. But then i tried to communicate with it from another machine and it doesn't work. First, on the host machine - after making sure the webapi is running - I type "ipconfig" to get the ip address (it's always using port 8081). Let's say the ip address of the host machine is 123.45.678.123... I then type into the browser on the other machine "http://123.45.678.123:8081/api/status", but this generates a "Hmm, we can't reach this page" error message. I am able to ping back and forth between the two machines but only after disabling the firewall on the client. What could be the problem here? Thank you in advance.

-L 

Calling ASMX web service in .NET Core class libarary

$
0
0

Please bear with me if I sound stupid since this is the first ever app I am working on .NET Core. I am working on an AWS Lambda project which is basically a .NET Core app. I have written core logic in a separate .NET Core Class library in the same solution of which, the project.json showing following framework information:
     "frameworks": {
        "netstandard1.6": {
          "imports": "dnxcore50"
        }

All is good to this point. I can call this Core class library functions in AWS Core lambda project. But, further now; I have to call a legacy ASMX Web service in .NET Core class library that I have created. So, I created a proxy class for ASMX Web service with the help of wsdl.exe and tried to add that class in .NET Core class library. It is apparent that it is not going to work since namespaces like System.Web.Services namespace is not available. So, I dig online on this part, and I came to one point that If I create a new .NEW Framework 4.6.x class library and add the proxy class to it and then I reference it inside my .NET Core class library, it may work.
My first doubt (for why I am here) is, what I am doing, is this feasible or this is something against the design? (I mean referencing a traditional .NET Framework 4.6.x class library dll to .NET Core class library).
My second doubt is, If this is feasible then how would I do it? When I try to add the reference, I am not able to access any of functions of referenced 4.6.x class library within .NET Core class library project. I am using Visual Studio 2015 Update 3 Community Edition with .NET Core SDK 1.0.0, MS .NET Core 1.0.1 Tooling Preview 2 installed for 2015.
Thank you for any help!

Nested foreach help - Cannot apply indexing with [] to an expression...

$
0
0

I am creating an excel spreadsheet and have an inner foreach of a column list and I am trying to get the outer foreach data dynamically based on the column name.  Instead of having if statements based on the column name I want to get the current row's data based on the "col" value.  I have highlighted the line below which is throwing me an error:

DocumentFormat.OpenXml.Spreadsheet.Row headerRow = new DocumentFormat.OpenXml.Spreadsheet.Row();
List<String> columns = new List<string>();
columns.Add("FirstName");
columns.Add("LastName");
columns.Add("Email");
foreach (String column in columns)
{
    DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
    cell.DataType = CellValues.String;
    cell.CellValue = new CellValue(column);
    headerRow.AppendChild(cell);
}
sheetData.Append(headerRow);

IEnumerable<Models.Data.Admin.User> theusers = Repository.Users().ToList();
foreach (var dsrow in theusers)
{
    DocumentFormat.OpenXml.Spreadsheet.Row newRow = new DocumentFormat.OpenXml.Spreadsheet.Row();
    foreach (string col in columns)
    {
        DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
        cell.DataType = CellValues.String;cell.CellValue = new CellValue(dsrow[col].ToString()); // dsrow[col] throws Cannot apply indexing with [] to an expression of type 'User'        newRow.AppendChild(cell);
    }
    sheetData.Append(newRow);
}



DocumentFormat.OpenXml.Spreadsheet.Row headerRow = new DocumentFormat.OpenXml.Spreadsheet.Row();                List<String> columns = new List<string>();                columns.Add("FirstName");                columns.Add("LastName");                columns.Add("Email");               foreach (String column in columns)                {                    DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();                    cell.DataType = CellValues.String;                    cell.CellValue = new CellValue(column);                    headerRow.AppendChild(cell);                }                sheetData.Append(headerRow);
                IEnumerable<Models.Data.Admin.User> theusers = Repository.Users().ToList();                foreach (var dsrow in theusers)                {                    //string test = dsrow.;
                    DocumentFormat.OpenXml.Spreadsheet.Row newRow = new DocumentFormat.OpenXml.Spreadsheet.Row();                    foreach (string col in columns)                    {                        DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();                        cell.DataType = CellValues.String;                        cell.CellValue = new CellValue(dsrow[col].ToString());                        newRow.AppendChild(cell);                    }                   sheetData.Append(newRow);                }

ASP.NET MVC – example of RequiredRouteConstraint (:required) use

$
0
0

I am not sure about RequiredRouteConstraint use. The definition sais“Constraints a route parameter that must have a value.” and”This constraint is primarily used to enforce that a non-parameter value is present during URL generation.”.

The route normally without parameter specified would not be matched if it is not optional parameter or if the default route not comply this case. So appending:required constraint to route parameter (e.g. {name:required}) seems useless to me.

How does look like example of RequiredRouteConstraint common use?

Viewing all 9386 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>