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

Upload files to database and return them

$
0
0

Hi

I am trying to find out how to upload files and store them in the database using .net core 2.1, I don't want to save the file on the server and save the path in the database, like all the examples I seem to be finding.

Does anyone have a link to an example of how to save the file in the database and then display it.

I am also going to need to change the size of the file,and possibly put the file onto a new canvass (in the middle) change the canvas colour.


ODBC with ASP.NET Core 2.2

$
0
0

Hi Folks

I'm developing an application ASP.NET Core 2.2 on .NET Framework 4.7.2 that needs access to SQL Server, MySQL, Sap Hana, and DB2 thruODBC.
I have installed the ODBC Driver on Windows, the user fill a form with credentials and send the form to validate the access

The app builds a connection string and opens a connection to validate the access. The problem is that only work with SQL Server when I try with MySQL, Oracle or other I got the error Message "[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".

The code I use to validate the connections string is in a separate .NET Framework Library and when I use it in a console app it works and when consuming it in ASP.NET CoreProject don't

using (OdbcConnection connection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};server=localhost;Port=3306;Database=sakila;Uid=user;pwd=Password;Option=3;"))
{
  try
  {
     connection.Open();
  }
  catch (Exception e)
{
// return error message
} }

Any Ideas how to solve it

403 forbidden error after publish ASP.NET Core

$
0
0

Hi,

I published my project ForOffer to web hosting server using Web deployment method via Visual Studio 2017. I've entered all server details and publish was successful. (see https://prnt.sc/n1tlmb) .from my side (in Visual Studio)

But when it opens the page error : 403 Forbidden comes. What might cause this? What I need to check and edit before publishing?

Value cannot be null when no records saved for partial!

$
0
0

Hi All

I have a main edit page consists of a lot of partial views called in it, When I'm trying to update data on the main edit page itself or any of its partial data, The data is updated successfully if there is at least one record of the called partial or else does not save and the action gives me this error: (when there is no records of the partial called)

ArgumentNullException: Value cannot be null.
Parameter name: source

The main model:

    public partial class Guests
    {
        public decimal Id { get; set; }
        public string FName { get; set; }
        public string SName { get; set; }
        public string ThName { get; set; }
        public string LName { get; set; }
        [Required]
        public string FullName { get; set; }
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
        [Required]
        public DateTime? BirthDate { get; set; }
        [Required]
        public int? SexId { get; set; }
        [Required]
        public int? HalaId { get; set; }
        public string ImageUrl { get; set; }
        public string UserId { get; set; }
        public DateTime InsertDate { get; set; }
        public string UpdateUser { get; set; }
        public DateTime? UpdateDate { get; set; }
        public Hala Hala { get; set; }
        public Sex Sex { get; set; }
        public ApplicationUser User { get; set; }

        public IList<Visit> Visit { get; set; }
    }

The child Visit model:

public partial class Visit
    {
        public int Id { get; set; }
        [Required]
        public decimal GuestId { get; set; }

        public DateTime VisitDate { get; set; }
        public int? VisitTypeId { get; set; }
        public bool SpecialStatus { get; set; }
        public string Notes { get; set; }
        public string UserId { get; set; }
        public DateTime InsertDate { get; set; }
        public string UpdateUser { get; set; }
        public DateTime? UpdateDate { get; set; }

        public Guests Guest { get; set; }
        public VisitType VisitType { get; set; }
        public ApplicationUser User { get; set; }
    }

The post Edit method of Guests controller:

 [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> Edit(decimal id, [Bind("Id,FName,SName,ThName,LName,FullName,BirthDate,SexId,HalaId,KafalaId,ImageUrl,UserId,InsertDate,UpdateUser,UpdateDate,Visit")] Guests guest)
        {
            if (id != guest.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var Edited = new Guests()
                    {
                        Id = guest.Id,
                        BirthDate = guest.BirthDate,
                        InsertDate = guest.InsertDate,
                        UserId = guest.UserId,
                        FullName = guest.FullName,
                        SexId = guest.SexId,
                        HalaId = guest.HalaId,
                        FName = guest.FName,
                        SName = guest.SName,
                        ThName = guest.ThName,
                        LName = guest.LName,
                        ImageUrl = guest.ImageUrl,
                        UpdateUser = guest.UpdateUser,
                        UpdateDate = guest.UpdateDate,

                        Visit = guest.Visit.Where(m => m.GuestId == guest.Id).ToList()/
                    };
                    _context.Update(Edited);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GuestsExists(guest.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }

            return View(guest);
        }

The Guests edit view:

@model Guests<meta charset="utf-8" dir="rtl"><meta name="viewport" content="width=device-width, initial-scale=1"><form asp-action="Edit"><div asp-validation-summary="ModelOnly" class="text-danger"></div><input type="hidden" asp-for="Id" /><input type="hidden" asp-for="InsertDate" /><input type="hidden" asp-for="UserId" /><input type="hidden" id="hdn_ha" asp-for="HalaId" /><div class="row"><div class="col-md-4"><h3>Guest Edit</h3></div><div class="col-md-4"></div></div><hr style="margin:0" /><div class="row"><div class="col-md-3"><label asp-for="FullName" class="control-label">Full Name</label><input asp-for="FullName" class="form-control" readonly /><span asp-validation-for="FullName" class="text-danger"></span></div><div class="col-md-3"><label asp-for="BirthDate" class="control-label">Birth Date</label><input asp-for="BirthDate" class="form-control" readonly /><span asp-validation-for="BirthDate" class="text-danger"></span></div><div class="col-md-3"><label asp-for="SexId" class="control-label">Sex</label><select asp-for="SexId" class="form-control" asp-items="ViewBag.SexId"></select><span asp-validation-for="SexId" class="text-danger"></span></div><div class="col-md-3"><label asp-for="HalaId" class="control-label">Hala</label><select asp-for="HalaId" class="form-control" id="ha" asp-items="ViewBag.HalaId" disabled></select><span asp-validation-for="HalaId" class="text-danger"></span></div></div><br /><div><ul class="nav nav-tabs"><li class="in active"><a data-toggle="tab" href="#home">Visits</a></li><li><a data-toggle="tab" href="#menu2">Another</a></li></ul><div class="tab-content">
            @*<div id="home" class="tab-pane fade in active">
            @{ await Html.RenderPartialAsync("~/Views/Visit/ParVisit.cshtml", Model); }</div></div><div class="form-group"><input type="submit" value="Save" class="btn btn-default" /></div></form>


@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script><script>$(document).ready(function () {
        var select_ha = $('#ha option:selected').val();$('#hdn_ha').val(select_ha);
    });</script>

The ParVisit view:

@model Guests<a asp-action="Create" asp-controller="Visit"><img src="~/images/icons8-add-new-480.png" style="background-color:blue" height="30" width="30" /></a><table class="table"><thead><tr><th>
                Visit Date</th><th>
                Visit Type</th><th>
                Special Status</th><th>
                Notes</th></tr></thead><tbody>
        @for (var i = 0; i < Model.Visit.Count; ++i)
        {<tr>
            @Html.HiddenFor(m => m.Visit[i].Id)
            @Html.HiddenFor(m => m.Visit[i].GuestId)
            @Html.HiddenFor(m => m.Visit[i].InsertDate)
            @Html.HiddenFor(m => m.Visit[i].UpdateDate)
            @Html.HiddenFor(m => m.Visit[i].UserId)
            @Html.HiddenFor(m => m.Visit[i].UpdateUser)
            @Html.HiddenFor(m => m.Visit[i].VisitTypeId)
            @Html.HiddenFor(m => m.Visit[i].Guest)<td width="15%">
                @Html.EditorFor(m => m.Visit[i].VisitDate)</td><td width="15%">
                @Html.DropDownListFor(m => m.Visit[i].VisitTypeId, (SelectList)ViewBag.VisitTypeId)</td><td width="15%">
                @Html.EditorFor(m => m.Visit[i].SpecialStatus)</td><td width="50%">
                @Html.EditorFor(m => m.Visit[i].Notes)</td></tr>
        }</tbody></table>

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

Now if there is one record at least in Visit table the action is saving changes correctly unless it gives me this error:

ArgumentNullException: Value cannot be null.
Parameter name: source

................................................

ArgumentNullException: Value cannot be null. Parameter name: source

  • System.Linq.Enumerable.Where<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)

  • NozCoreWebApp7.Controllers.GuestsController.Edit(decimal id,

    Guests guest) in GuestsController.cs

<div class="source">

  1. }
  2. if (ModelState.IsValid)
  3. {
  4. try
  5. {
  1. var Edited = new Guests()
  1. {
  2. Id = guest.Id,
  3. BirthDate = guest.BirthDate,
  4. InsertDate = guest.InsertDate,
  5. UserId = guest.UserId,
  6. FullName = guest.FullName,

Why? and How to solve please?

Custom RazorPages Location Formats (Name Patterns)

$
0
0

Is it possible to change the name pattern used for RazorPages like it is possible for Razor MVC Views?

You can change the MVC Views name pattern like this:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
    .AddRazorOptions(razorOptions => {
        razorOptions.ViewLocationFormats.Add("/Views/MvcPages/{1}/{0}.cshtml"); // Controller/Action
        razorOptions.ViewLocationFormats.Add("/Views/MvcPages/{1}/{1}{0}.cshtml"); // Controller/ControllerAction (intended for paths like Home/HomeIndex.cshtml)
        razorOptions.ViewLocationFormats.Add("/Views/Partials/{0}.cshtml"); // PartialName
});

I want to have something like "/Views/RazorPages/{1}/{1}{0}.cshtml" for RazorPages because its annoying to work with multiple open Razor files when several of them is called "Index.cshtml" and I can not tell them apart without switching to them or hovering the cursor over them to see the file path.

I have found I can do like this but it only changes where Razor starts looking for Razor pages and not how they are matched

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
    .AddRazorPagesOptions(pagesOptions => {
        pagesOptions.RootDirectory = "/Views/RazorPages";
    });

And if I do like this it only affects partials called from Razor Pages:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
    .AddRazorOptions(razorOptions => {
// Notice the method begins with Page, unlike in the first code snippet
razorOptions.PageViewLocationFormats.Add("/Views/Partials/{0}.cshtml"); });

I want to have a rule similar to what I have shown above and if it can be avoided not some kind of attribute I need in all index pages

Reasons for cross platform and performance in asp.net core

$
0
0

After studying asp.net core for a while, Here are the conclusions that I could come of:

  1. It is fast: The reason according to me is the new request pipeline and middleware things that are modular and should be manually configured helping us to use only the components required.
  2. It is cross-platform: The reason according to me is the introduction of the new Kestrel server (Used only in OutOfProcess hosting model). This is cross-platform and this helps in running our application in Linux environment which was not possible earlier.

But few of my friends have misconception regarding the above points. They say it is fast because the razor views are also bundled and minified in the new core projects inside of wwwroot and for it being cross platform, there are separate dlls created by our solution for windows and linux environment which makes it cross-platform. So can anyone here help me in telling the true reasons for asp.net core being fast and cross-platform?

A few API questions

$
0
0

Hi

I am changing my web app from mvc to core, and I am changing from razor to angular.

I have started building and would prefer to put my API in a seperate project to the angular, whats the best way to achive this, would it be in a better having two solutions and running them both at the same time?

Also when the API is made public over the internet how do i protect it from unauthorised websites or requests accessing it, I know how to authorise users i will be using identity when people need to be logged in, but how do i make sure it is along accessed by the websites i want, is that at server level or something i need to code in?

Any suggestions would be appriciated.

Get cookies from external website after authentication

$
0
0

Hi All,

I have been a C++ developer all my life. So i am new to asp.net and web technologies as such. 

I need to develop a small cross-platform application, which will basically open an external website. And allow the user to sign-in (username and password). Once the user is authenticated, this application needs to fetch the cookies and hand it over to a C++ desktop application. It is basically SSO credentials, so the website redirects to a page where the authentication happens.

For this, i have written some code, which for now opens the website. But i am cluless on how to get the cookies and hand it over to the C++ app.

//Program.cs 

class Program { static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseStartup<Startup>() .Build(); host.Start(); OpenBrowser("https://mywebsite.com/auth/samlsso.php"); } public static void OpenBrowser(string url) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Process.Start(new ProcessStartInfo("cmd", $"/c start {url}")); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("xdg-open", url); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Process.Start("open", url); } else { // throw } } }

 //startup.cs

namespace SampleCore
{
    public class Startup
    {
        public void Configure(IApplicationBuilder builder)
        {
            builder.Run(appContext =>
            {
                return appContext.Response.WriteAsync("Hey, I'm from Web!");
            });
        }
    }
}


Introduction to Reactive UI: what can it offer our companies?

$
0
0
<div class="fusion-title title fusion-sep-none fusion-title-size-two title-about fusion-border-below-title">

About the webinar

</div> <div class="fusion-text">

This webinar will provide an introduction into what Reactive UI is, what programming model it is based on, and how to integrate it into applications using MVVM. A series of simple applications will also be presented as a use case of this framework.

</div>

ASP.Net 4.5 to ASP.Net core 2.0.1 migration issue of Authentication

$
0
0

Hello Developers, I am new to ASP.Net core 2.0.1, i studied the architecture of Authentication and identification in core framework,i facing some problems during migration, please help. In the Startup.cs file, I am using this piecce of code in ConfigureServices method

<div class="pre-action-link" id="premain926311">Hide   Copy Code</div>
app.use(async (context, next) =>
            {
// When the user is already authenticated, check if the session is still alive, if not, log him out.
//do something
await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
                    await context.Authentication.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme);
//OR 
 await next.Invoke();
}



Now in core, i dont know how to handle these 2 functions for logout

I get NULLREFERENCE Exception

<div class="pre-action-link" id="premain916634">Hide   Copy Code</div>
var projectId = context?.Session?.GetInt("Project_Id");

when page is refershed after a while.

Please help me to resolve these issue.

<div class="signature">Geetha</div>

Migrate Console App to .Net Core

$
0
0

One of my Client wants to migrate a console app (having System.Web dlls) to .Net Core. Do we have any relevant mapping tool which shows corresponding methods of System.Web to .Net Core.

Currently .Net portability analyzer only provides a report showing whether app can be ported or not, for relevant corresponding method mappings etc. client has to use MS docs and then do relevant method calls for .net core.

Any suggestions or recommendations or any tool which can provide relevant method replacements or make migration easier?.

Thanks In Advance!!!..

Missing files in Publish folder

$
0
0

When publishing a web application all the files / assemblies get copied to the published folder. I have a console app, with System.Web dll's referencing it. While publishing the console app, there are some files which do not get copied in the publish folder like appsettings.json

The appsettings.json gets copied in publish folder only if we add an attribute <copytooutputdirectory>Always</copytooutputdirectory>,in the config.

Currently this is a problem, any idea in which future .net core versions this would get fixed?. (This issue is also highlighted on github as well, i guess).

Asp.Net Core 2.2 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

$
0
0

<div>I'm developing an application in Asp.Net 2.2.</div> <div>I made the application public via FTP.</div> <div> </div> <div>When I access the service with my application I get the following error.</div><div> </div> <div>The hosting service tells me that something is missing for me to do, and that the fault is not from the server.</div> <div> </div> <div>The application works perfectly on localhost.</div><div> </div> <div>I'm waiting</div> <div></div> <div>

HTTP Error 500.0 - ANCM In-Process Handler Load Failure</div> <div>Common causes of this issue:</div> <div>The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.</div> <div>The in process request handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the application.</div><div>ANCM could not find dotnet.</div> <div>Troubleshooting steps:</div> <div>Check the system event log for error messages</div><div>Enable logging the application process' stdout messages</div> <div>Attach a debugger to the application process and inspect</div> <div>For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028526</div>

Re: Asp.Net Core 2.2 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

$
0
0

This was happening to me when I was trying to webdeploy a dotnet core 2.2 into an IIS server. Another thing that worked for me but isn't necessarily right is to actually change the handler in the web.config from
<handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule**V2**" resourceType="Unspecified" /> </handlers>
to
<handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers>

Thank you

unknown error while processing HTTPS certificate

$
0
0

Hi!
I'm trying to build a .NET Core server that uses a HTTPS connection.

I created a self-signed certificate using dotnet dev-certs tool and set up Kestrel like this:

    return WebHost.CreateDefaultBuilder(args)
                    .UseKestrel(options =>
                    {
                        options.Listen(IPAddress.Loopback, 5000, lisOpt => lisOpt.UseHttps("myCert.pfx", "test"));
                    })
                  .UseStartup<Startup>()
                .Build();

But when I try to connect to it with my client, I keep getting this exception:

fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate
   --- End of inner exception stack trace ---
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslState.ThrowIfExceptional()
   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__50_2(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.FrameConnection.ApplyConnectionAdaptersAsync()
fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate
   --- End of inner exception stack trace ---

What am I doing wrong?
thanks!


Is there any way to do an integration test with .net core (TestServer) and web api code write in .net framework?

$
0
0

My WebApi is write in .NET Framework, but i like to use the new integration test using .net core, becouse TestServer to make a server in memory is so fantastic and easy to use. But when i try to start the server some error occurs. My question is, there is any way to write some .net core test and .net framework webapi?

Test in .NET Core

publicUnitTest1(){var builder =newWebHostBuilder().UseStartup<Startup>();

    _testServer =newTestServer(builder);Client= _testServer.CreateClient();Console.WriteLine("Teste");}

My Startup Class in .NET Framework

publicclassStartup{publicvoidConfiguration(IAppBuilder app){// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888
            app.UseApplicationInsights();ConfigureOAuth(app);GlobalConfiguration.Configure(WebApiConfig.Register);

            app.UseWebApi(GlobalConfiguration.Configuration);SimpleInjectorInitializer.Initialize(app);}publicvoidConfigureOAuth(IAppBuilder app){OAuthAuthorizationServerOptionsOAuthServerOptions=newOAuthAuthorizationServerOptions(){#if DEBUGAllowInsecureHttp=true,#elseAllowInsecureHttp=false,#endifTokenEndpointPath=newPathString("/token"),AccessTokenExpireTimeSpan=TimeSpan.FromMinutes(double.Parse(ConfigurationManager.AppSettings["AccessTokenExpireInMinutes"])),Provider=newADAuthorizationServerProvider(),RefreshTokenProvider=newRefreshTokenProvider()};// Token Generation
            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(newOAuthBearerAuthenticationOptions());}}

Error on UnitTest1 in _testServer line:

System.InvalidOperationException: 'A public method named 'ConfigureProduction' or 'Configure' could not be found in the 'MRV.Obras.Mobile.Host.WebApi.Startup' type.'

Checking DateTime equality to DateTime.Now failed.

$
0
0

Hi guys,

I have posts with expiration dates. I wanted to check that if the ExpirationDate is equal to DateTime.Now, remove that post from database in order not to get it in view from there. 

I added the following code to Posts view in relevant action (for ex) of the PostController:

 public async Task<IActionResult> Posts()
        {
            AdminPostModel postModel = new AdminPostModel();
            postModel.Posts = await _offerDbContext.Posts.ToListAsync();
            foreach(Post item in postModel.Posts)
            {
                if(item.ExpirationDate == DateTime.Now)
                {
                    _offerDbContext.Posts.Remove(item);
                    await _offerDbContext.SaveChangesAsync();
                }
            }
            Return View(postModel);
        }

And in view, I call properties of posts, of course

@model Foroffer.Models.ViewModels.AdminPostModel
 @foreach (Post item in Model.Posts)<div class="row"><div class="col-lg-3 col-md-4 col-sm-6 col-12"><div class="post"><div class="heading"><div class="row"><div class="col-lg-4 col-md-4 col-sm-4 col-4"><img class="postlogo" src="~/images/@item.Company.LogoPath"></div><div class="col-lg-8 col-md-8 col-sm-8 col-8"><div class="titles"><p class="ptitle">@item.Company.Name</p><p class="address"><b>Ünvan:</b> @item.Company.Address</p><a href=""><p>Bütün ünvanlar</p></a></div></div></div></div><div class="postcontent"><div class="row"><div class="col-lg-12 col-md-12"><div class="uppart"><h6>@item.Title</h6></div><img class="postimg" src="~/images/@item.Image"><div class="posttext"><p>
                                            @item.Description</p><p class="formore"><strong>Ətraflı:</strong><a href="@item.URL" target="_blank">BURADA</a></p></div><div class="dates"><p class="postdate">Tarix: @item.CreatedDate.ToString("dd/MM/yyyy") _________</p><p class="expdate">Bitme tarix: @item.ExpirationDate.ToString("dd/MM/yyyy") </p></div></div></div></div>
                 ---continued

I think the problem may lie in formatting as in SQL dates presented like 2019-03-26 00:00:00.000000. But while debugging it showed  2019-03-26 0:00:00 in Visual Studio. There may also be additional things that compiler reads and check which I may miss. But I actually need it to check only Date & Time, and time for 0:00 when the day starts as I didn't set time for expiration dates. 

Anyone has good idea?

Error In OrderBy OnGet Handler

$
0
0

Hello,

Using ASP .Net Core (2.2) Razor Pages (non-MVC)

I have a "Person" Class (Id, FirstName, LastName, etc....)

In my OnGet Handler, in the Index.cshtml file,  I am getting an error, on the .OrderBy Operator:


public IList<Person> Person { get; set; }

public async Task<IActionResult> OnGet()
{
var result = await _db.Person.ToListAsync();
Person = result.OrderBy(x => x.Name);
return Page();
}


Error CS1061

'List' does not contain a definition for 'OrderBy' and no accessible extension method 'OrderBy' accepting a first argument of type 'List' could be found (are you missing a using directive or an assembly reference?)

Any help appreciated in understand how to correct this.

Is there any js script or any method to export into excel and pdf from the list variable or modal

$
0
0

Hi 

I am trying to export the record   into excel and pdf   .  Have you any suggested script or code to export in to excel from the Model  or from the  List variable. If you have please can you advise what is the script and how can I use that?

With Many Thanks

Pol

how can I show a part of the view from the controller

$
0
0

I have two  <Div>s in an html, 1. ReportSection 2.  ExcelSection in AttendanceReport view html. When I call the view from controller , the DivID   Excelsection  should not be  execute. Rest of all part should be executed. But when I click  PrintExcel button , only execute Excel Section but not execute  Report section .  Please can you give the suggested code to implement this functionality .

Thanks

Pol

Controller

 public IActionResult AttendanceReport(ReportViewModel report)
        {
 return View("AttendanceReport", report);

}
<div class="col-sm-4">  <button type="button" class="btn btn-primary form-control col-sm-3" onclick="PrintExcel()">Export Excel</button></div><div id="ReportSection"><table id="tdAttendanceReport" class="table table-bordered table-striped" style="width:100%; table-layout: fixed;word-wrap: break-word" ><thead><tr><th>Date</th><th>Name</th><th>Position</th><th>Office</th><th>Clocked in</th><th>Clocked Out</th><th>N. Attendance</th><th>Day off</th><th>Sick</th><th>Holiday</th><th>Time Off</th><th>Time Off Hrs</th><th>Age</th><th>Start date</th><th>Salary</th><th>Comment</th></tr></thead><tbody><tr><td> 20/03/2019</td><td>Tiger Nixon</td><td>System Architect</td><td>Edinburgh</td><td> 00:00</td><td> 00:00</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td>61</td><td>2011/04/25</td><td>$320,800</td><td>sdkjfhsdh s dofhsdfh sdiufuisfi iufhi s uifi s iuf sdif</td></tr></tbody></table></div><div id="ExcelSection"><table id="tdAttendanceExcel" class="table table-bordered table-striped" style="width:100%; table-layout: fixed;word-wrap: break-word" ><thead><tr><th>Date</th><th>Name</th><th>Position</th><th>Office</th><th>Clocked in</th><th>Clocked Out</th><th>N. Attendance</th><th>Day off</th><th>Sick</th><th>Holiday</th><th>Time Off</th><th>Time Off Hrs</th><th>Age</th><th>Start date</th><th>Salary</th><th>Comment</th></tr></thead><tbody><tr><td> 20/03/2019</td><td>Tiger Nixon</td><td>System Architect</td><td>Edinburgh</td><td> 00:00</td><td> 00:00</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td> 1</td><td>61</td><td>2011/04/25</td><td>$320,800</td><td>sdkjfhsdh s dofhsdfh sdiufuisfi iufhi s uifi s iuf sdif</td></tr></tbody></table></div>

Viewing all 9386 articles
Browse latest View live


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