Friday, August 16, 2019
Sunday, August 11, 2019
Access control allowed or cors allow
1. Access-Control-Allow-Origin
2.Access-Control-Allow-Headers
3.Access-Control-Allow-Methods
all allowed globaly (in web.config)
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
2.Access-Control-Allow-Headers
3.Access-Control-Allow-Methods
all allowed globaly (in web.config)
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
Web.config connection
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<connectionStrings>
<!--<add name="cm_connection" connectionString="Data Source=AS-RIN;Initial Catalog=web_inc;User ID=sa;Password=mdts888" providerName="System.Data.SqlClient" />-->
<add name="db_connection" connectionString="Data Source=OMG;Initial Catalog=test;User ID=sa;Password=mdts888" providerName="System.Data.SqlClient" />
<!--<add name="cm_connection" connectionString="Data Source=sql5026.site4now.net;Initial Catalog=DB_A45CFD_rinkesh;User ID=DB_A45CFD_rinkesh_admin;Password=Rin@123456#" providerName="System.Data.SqlClient"/>-->
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Saturday, August 10, 2019
Null Function in c# or null method in c#
decimal? net_value(decimal? BASIC, decimal? WD, decimal? AB)
{
return BASIC - ((BASIC / WD) * AB);
}
{
return BASIC - ((BASIC / WD) * AB);
}
Thursday, August 8, 2019
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Solution Link
1
2.
3. Default Document must be Index.html or Default.aspx in IIS
Tuesday, August 6, 2019
Thursday, August 1, 2019
Core 2.2 db connection or Core 2.2 database connection
1. Update in root file appsettings.json like web.config
{
"ConnectionStrings": {
"DefaultConnection1": "Server=omg;Database=test;User Id=sa;Password=mdts888;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
2. Update in Startup.cs
services.AddDbContext<db_context>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection1")));
services.AddDbContext<db_context_>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection1")));
3.
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApplication6.Models;
namespace WebApplication6.Auth
{
public class db_context : IdentityDbContext
{
public db_context(DbContextOptions<db_context> options)
: base(options)
{
}
public DbSet<WebApplication6.Models.customer> customer { get; set; }
}
public class db_context_ : DbContext
{
public db_context_(DbContextOptions<db_context> options)
: base(options)
{
}
public DbSet<WebApplication6.Models.customer> customer { get; set; }
}
}
4. Installed Package
{
"ConnectionStrings": {
"DefaultConnection1": "Server=omg;Database=test;User Id=sa;Password=mdts888;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
2. Update in Startup.cs
services.AddDbContext<db_context>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection1")));
services.AddDbContext<db_context_>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection1")));
3.
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApplication6.Models;
namespace WebApplication6.Auth
{
public class db_context : IdentityDbContext
{
public db_context(DbContextOptions<db_context> options)
: base(options)
{
}
public DbSet<WebApplication6.Models.customer> customer { get; set; }
}
public class db_context_ : DbContext
{
public db_context_(DbContextOptions<db_context> options)
: base(options)
{
}
public DbSet<WebApplication6.Models.customer> customer { get; set; }
}
}
4. Installed Package
Subscribe to:
Posts (Atom)
Raw Insert query in EF8 or Entity Framwork 8
public async Task<object> InsertRack(Rack RackInsert) { try { sql = " i...
-
1. Customer Form Authentication Set on Controller 2. Set On Web config 3. Add Authentication Filter 4. Use Athentication Filter...
-
There are three of dependency injection executer, we will she their life time cycle 1. Scoped > It does not go to life time 2. Transient...
-
*. Return view with another folder *. Return view with another conroller return View("~/Views/Home/invoice.cshtml", model_name);






