Subscribe: Custom Server Controls
http://forums.asp.net/rss.aspx?ForumID=19
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
code  context  core web  core  data  function  list  microsoft  net core  net  new  public  script  server  text  var  web 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Custom Server Controls

All Forums



All Forums



Last Build Date: Thu, 17 Aug 2017 06:54:47 -0700

 



ASP developer needed

2016-04-28T18:29:36.957-07:00

Hi all,

I am in need of a developer to help us with our site. ASP.net

Help would be very appreciated!

Craig

admin@artyah.com




Data does not show on Table using Ajax

2017-08-17T07:41:38.08-07:00

I am trying to display data on table using ajax but it does not display on table

here is my ajax code:

@section scripts{
    
    

    
   
    }

But View shows data like this

[{"Merit":151,"FormNo":1111,"Name":"xyzabc","Status":0}]



ASP .NET Core - Windows Service - Make it secure using https

2017-08-01T15:06:38.293-07:00

Hello:

I have ASP .NET Core web API running as a windows service on a port, 60001.

public static void Main(string[] args)
        {
            bool isService = true;
            if (Debugger.IsAttached || args.Contains("--console"))
            {
                isService = false;
            }

            var pathToContentRoot = Directory.GetCurrentDirectory();
            if (isService)
            {
                var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
                pathToContentRoot = Path.GetDirectoryName(pathToExe);
            }


            var config = new ConfigurationBuilder()
                //.SetBasePath(Directory.GetCurrentDirectory())
                .SetBasePath(pathToContentRoot)
                //Specifying the IP or host ASP.NET Core listens on
                .AddJsonFile("hosting.json", optional: false, reloadOnChange: true)
                .Build();



            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(pathToContentRoot)
                .UseConfiguration(config)
                .UseIISIntegration()
                .UseStartup()
                .UseApplicationInsights()
                .Build();


            if (isService)
            {
                host.RunAsService();
            }
            else
            {
                host.Run();
            }
        }

After the Windows Service is started, I'm able to access it using http://machinename:60001/api

Now, the requirement is to make it secure with https. I do have purchased a SSL certificate available (NOT self signed) and I'm wondering how would I apply the certificate since I'm running it as a Windows Service. 

Any help will be appreciated.




Remove text from html page with javascript?

2017-08-15T15:38:15.99-07:00

Hi I've a webpage which generates some text 'TheNavigationTree' before the page starts. Can I remove it with javascript? thanks p TheNavigationTree < html __expr-val-dir="ltr" dir="ltr"> < head> How to handle a POSTed file to an ASP.NET Core application from Microsoft Flow

2017-08-17T13:34:30.947-07:00

I have a Microsoft Flow setup with the following steps When a file is created (SharePoint) (this is pointing to a specific document library Http (Http), Method: Post, Uri (pointing to my app), Body: File Content from the SharePoint step above. My app that I have written is hosted in an Azure Web App and is written in C# in ASP.NET Core.  I'm trying to convert the information that is coming into me from Flow back into the original document and I cannot figure out what is being sent.  When I look in Flow it says the body of the request that was sent is: { "$content-type": "image/jpeg", "$content": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAQABADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD1C9EMuqzGK1juS+3P7rccgc4yMYxjv1q/ol0I4bfTpQVniXaoyDuQHjoTg7ccGsDU7O+0+xEdoJfMUKiKE84MB/dJ5B9mzj6VneFtO1271qx1G+hubaGBjmCSUfMSMZZQNoxzgDnPfGKqcnypEJW1R//Z" } In my application I originally tried to have a method that looks like  [HttpPost] public IActionResult Process(List files) but that flow is not submitted a file, so I changed it to the below method [HttpPost] public IActionResult ProcessJson([FromBody]FlowFile file) {... } public class FlowFile { [JsonProperty(PropertyName = "$content-type")] public string ContentType { get; set; } [JsonProperty(PropertyName = "$content")] public string Content { get; set; } } I also added a block of middleware, so that I could get the actual request body stream.  The middleware that I added has method that looks like this public async Task Invoke(HttpContext context) { var requestBodyStream = new MemoryStream(); var originalRequestBody = context.Request.Body; await context.Request.Body.CopyToAsync(requestBodyStream); requestBodyStream.Seek(0, SeekOrigin.Begin); var requestBodyText = new StreamReader(requestBodyStream).ReadToEnd(); var bytes = StringToByteArray(requestBodyText); LogRequestMiddleware.LastBody = System.Text.Encoding.Default.GetString(bytes); requestBodyStream.Seek(0, SeekOrigin.Begin); context.Request.Body = requestBodyStream; await next(context); context.Request.Body = originalRequestBody; } private static byte[] StringToByteArray(string hex) { return Enumerable.Range(0, hex.Length) //.Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 1), 8)) .ToArray(); } When I do this The response that I get is below and I cannot figure how to get it back to the correct string that I want. �����JFIF��`�`�����C�   &#[...]



How to replace Core MVC Carousel first image

2017-07-31T20:26:57.86-07:00

Hello,

I created an ASP.NET Core 1.1 MVC Web Application in Visual Studio 2017 Community.

I am trying to replace the first image in the carousel on the Home page with a link coding from my Microsoft affiliate account.

Here is what the original Index.cshtml first item code looks like:

         
(image)

Here is the code that I get from the affiliate website:

          

I tried to modify the code for the first carousel image to look like this:

         
(image)

        

It displays the image, but it does not allow me to click it for the destination URL and the navigation arrows and dots do not appear correctly.  This is what it looks like:

(image)

I understand that the original image that is displayed is the wwwroot\images\banner1.svg file.  I do not want to replace that file.  I want to replace the image that is displayed in the carousel.

Does anyone know how I can get this coding to work as one of the items in the carousel?

Thanks,
Tony




Asp.Net Core Identity Problem

2017-08-01T14:48:26.057-07:00

We are publishing an application on smartadmin.com.br We used asp.net core 1.1 and we are using Identity to make the users control. There are 2 problems: 1. I can not shut down the idle time, so, if user stays X time, the system redirect to login again, i want disable this... 2. The app requests login at all times, even working on the system, ie:  User is working and SURPRISE! it redirects to the login, after informing the login it comes back, and he works,, works,, AND SURPRISE! redirect to login... this is very bad ... this my Startup.cs using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SmartAdmin.Services; using Smart.Data.Context; using Smart.Core.Interface.Base; using Smart.Data.Repository; using Smart.Core.Identity; using SmartAdmin.Helpers; using Microsoft.AspNetCore.Mvc.Razor; using System.Globalization; using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Http; using Smart.Services.Interfaces; using Smart.Services.Entity; using SmartAdmin.Formatters; using Microsoft.Net.Http.Headers; using AutoMapper; namespace SmartAdmin {     public class Startup     {         public Startup(IHostingEnvironment env)         {             var builder = new ConfigurationBuilder()                 .SetBasePath(env.ContentRootPath)                 .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)                 .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);             if (env.IsDevelopment())             {                 // For more details on using the user secret store see https://go.microsoft.com/fwlink/?LinkID=532709                 builder.AddUserSecrets();             }             builder.AddEnvironmentVariables();             Configuration = builder.Build();         }         public IConfigurationRoot Configuration { get; }         // This method gets called by the runtime. Use this method to add services to the container.         public void ConfigureServices(IServiceCollection services)         {             var csvFormatterOptions = new CsvFormatterOptions();             services.Configure(Configuration);             services.AddOptions();             var appConfig = Configuration.GetSection("Settings").Get();             services.AddSingleton



How to call asp.net xml web services (.asmx) from an asp.net core web api?

2017-08-03T17:24:41.47-07:00

I have a asp.net core web api project and now I would like to know how to call xml web services from it? I used to add web references from .net framework projects.




.net core 1.1 web application deployment on ubuntu 16.04

2017-07-31T20:17:54.003-07:00

I have deployed .net CORE 1.1 web application on ubuntu 16.04 server, but it wont show on the browser, neither log the errors via  the supervisor utility.

Please anyone knows why its not logging?

Regards,

John




How to? Deploy .NET core web app developed with Visual Studio 2017 to Ubuntu 16.04 Server

2017-08-01T01:15:09.97-07:00

Hi,

I know it is possible to deploy a .net core web app developed in Visual Studio, to Ubuntu 16.04, but the knowledge base provided by Microsoft only details about setting up a host environment  "Set up a hosting environment for ASP.NET Core on Linux with Nginx, and deploy to it" but not how the whole process from packaging the app through to deployment.    

Anyone who has gone the process please help with the key steps from packaging through deployment.

Thanks,

John. 




Custom urls in asp.net core 2

2017-08-06T08:24:34.197-07:00

I was wondering how does one achieve custom database based urls for asp.net core 2 does anybody have any code or tips that they can share.




IrouteConstraint how to do in asp.net.core

2017-08-05T16:12:26.953-07:00

I am trying to create a IrouteConstraint for a cms controller to match on slugs. However I am using asp.net core and I cant seem to find a way to resolve httpcontextbase. I was going by the msdn

https://msdn.microsoft.com/en-us/library/system.web.routing.irouteconstraint(v=vs.110).aspx

[TypeForwardedFrom("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
public interface IRouteConstraint
{
    bool Match(HttpContextBase httpContext, Route route, string 
    parameterName, RouteValueDictionary values, RouteDirection routeDirection);
}

Obv I cannot reference system.web as its not in asp.net core so what do I reference in asp.net core 1.2 to get this to work or is their a new way of doing this.

Basically what I want to achieve is www.yourdoamin.com / friendly url then if a person choose a parent category it would go www.yourdomain.com/category/friendlyurl cms driven page.

Base in mind im using lattest asp.net core

I no I will need a controler like CmsController with the pages and actions to write the field that will house the content what is the best way also to output the content to the view these days is it still output to something like a litterial control?




bootrap typeahead not working on the page throwing error.

2017-08-17T13:30:28.83-07:00

Hello all,

I am working on page where i am developing the bootrap typeahead in the page. but its throwing error.
Uncaught TypeError: $(...).typeahead is not a function

Below is my code.


 
   
    
    
    
	
	
    
	
	
    

I am trying to change position of js libraries. But no luck. Can anyone help me whats is wrong in the code.

Thanks in Advance.

Omkar.




ASP.NET Core Authentication problem on Windows Server 2008

2017-08-07T11:22:51.78-07:00

After publishing an ASP.NET Core MVC app to a Windows Server 2008 host and trying to authenticate in I get a "This page can’t be found".

The guide I've used to set it up: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis

On a local machine everything's perfect but on production server it just won't authenticate even though it's pointing to the same database.

Logging doesn't help much, all I get is:

No webpage was found for the web address: http://servername/TestApp/Account/Login?returnurl=%2FTestApp%2F

Log:

2017-08-07 09:24:37 10.202.17.20 POST /TestApp/Account/Login returnurl=%2FTestApp%2F 80 - 10.202.18.175 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/60.0.3112.90+Safari/537.36 http://servername/TestApp/Account/Login?ReturnUrl=%2FTestApp%2F 404 0 0 2234

I'm using AspNetCore 1.1.0 and AspNetCore.Identity.EntityFrameworkCore 1.1.0

I suspect something related to Identity is not working on live server but how can I diagnose it? Stdout is enabled in web.config but I'm not getting any error logs.




Applying the concept of VB Module in C#

2017-08-09T19:48:30.55-07:00

So I used to write my functions in VB module and call them from any  place in the project, I don't know how to do it in C#.

This is my current function in the controller

private readonly ApplicationDbContext _context;

        public PatRegController(ApplicationDbContext context)
        {
            _context = context;
        }

  public Int64 GetSerial()
        {
            List NewFileSeq = new List();
            NewFileSeq = _context.FileIdSeq.FromSql("FileIdSeqSP").ToList();
            var FileID = NewFileSeq[0].LastSequence;
            return FileID;
        }

and I call it 

GetSerial()

Now I moved it to another static class so I can initialize it from any place as follows

namespace ARTNetCore.Functions
{
    public static class DbSerializers
    {
        private static readonly ApplicationDbContext _context;
        public static Int64 FileIdSerial() {
            List NewFileSeq = new List();
            NewFileSeq = _context.FileIdSeq.FromSql("FileIdSeqSP").ToList();
            var FileID = NewFileSeq[0].LastSequence;
             return FileID;
        }
    }
}

and I call it in my controller like,

[HttpPost]
        [ValidateAntiForgeryToken]
        public async Task Create([Bind("FName,MName,LName,Dob,GenrId,StasId,NatyId,MarsId,CouyId,StaeId,CityId,OccnId,Email,SNN,PassNo,MobNo,LLine,MAdds,StrtNo,SDirn,AptNo,Locy,ALevl,PCode,Couy,ProeId")] PatReg patReg)
        {
            if (ModelState.IsValid)
            {
                patReg.FileId = DbSerializers.FileIdSerial();
                _context.Add(patReg);
                await _context.SaveChangesAsync();
                return RedirectToAction(nameof(Index));
            }
            return View(patReg);
        }

But I m getting an error 

An unhandled exception occurred while processing the request.

NullReferenceException: Object reference not set to an instance of an object.
NewFileSeq = _context.FileIdSeq.FromSql("FileIdSeqSP").ToList();

what am i missing here




Edit/Insert data in WebGrid bind to List

2017-08-16T22:16:32.557-07:00

Hello,     In my ViewModel, I have a List list. I retrieve data dynamically and display in WebGrid. In a toolbar, I have buttons for Edit/Insert/Del. I don't get a way of how can I make that dynamic data editable. User can edit it or insert it or delete a selected row.  Here's my code : public class MemberIndexViewModel { public List DataToDisplay { get; set; } public List Columns { get; private set; } public void GetData(string sql, int skipRecords) { // OTHER CODE to Operate SQL // Get the Columns RetrieveColumns(dt); // Convert to List ConvertDataTableToList(dt); return; } private void RetrieveColumns(DataTable dt) { Columns = new List(); //WebGrid wc = new WebGrid() foreach(DataColumn dc in dt.Columns) { WebGridColumn wc = new WebGridColumn(); wc.ColumnName = dc.ColumnName; wc.Header = dc.ColumnName; wc.CanSort = true; Columns.Add(wc); } return; } /// /// Converts DataTable into List type /// /// DataTable to be converted. private void ConvertDataTableToList(DataTable dt) { DataToDisplay = new List(); foreach (DataRow row in dt.AsEnumerable()) { IDictionary dn = new ExpandoObject(); foreach (DataColumn col in dt.Columns) dn[col.ColumnName] = row[col]; DataToDisplay.Add(dn); } return; } View Code : @model DataStudio.Models.MemberIndexViewModel @{ ViewBag.Title = "Member's Main Page"; Layout = "~/Views/Shared/_MemberLayout.cshtml"; var grid = new WebGrid(canPage: true, rowsPerPage: Model.RowsPerPage, canSort: true); grid.Bind(source: Model.DataToDisplay, rowCount: Model.TotalRecords, autoSortAndPage: false); }
@grid.Table( tableStyle: "table table-responsive table-bordered", rowStyle: "table-tr-odd", [...]



Windows Authentication to make SQL Server Connection

2017-08-04T15:08:06.7-07:00

Hello:
I have a .NET Core Web API Service which requires to connect to the SQL Server database using Windows Authentication. This is how it should work (raw):
1) The Windows username and password will be passed to the service method.
2) With the supplied username and password the service will make a trusted windows authentication to the SQL Server database.
I'm not sure how I will make use of the Windows Identity classes to build this.
Any help will be appreciated.




can i host asp.net core website on linux server?

2017-08-10T12:12:20.49-07:00

can i host asp.net core website on linux host server?

i have godaddy linux shared hosting server plan which comes with cpanel. In this case, how can i do this?




CRUD Operation in .net core 1.1 using angular 2

2017-08-11T16:28:05.703-07:00

Hi,

I want a sample application which uses .net core 1.1 and angular 2 for crud operation .

The application should have a grid which should have all the features to add , edit and delete records.

Thanks in Advance.




Adding Controller with views using Entity Framework Error - Visual Studio 2017 Preview (2)

2017-08-14T20:34:44.74-07:00

I'm cross posting this because it might make more sense here vs the Visual Studio MSDN forum.

Trying to follow the tutorial for the MVCMovie project located at :

https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-model

Getting the following error when trying to add a controller to the project.  Error is:

Scaffolding failed to edit Startup class to register the new Context using Dependency Injection. Make sure there is a Startup class and a ConfigureServices method and Configuration property in it.

I can add an empty controller and a controller with read/write actions, just not the one with the EF framework.

Any ideas other than waiting for an update to the IDE?

Thanks