Subhash Sharma

Subhash Sharma
Subhash Sharma

This is Subhash Sharma(Software Engineer) Blog

Welcome to this blog and find every solution.............

Search This Blog

Software Engineer(Subhash Sharma)

Software Engineer(Subhash Sharma)
Software Engineer

Saturday, October 15, 2022

Enable CORS in DotNet core in Startup.cs file

Browser security prevents a web page from making requests to a different domain than the one that served the web page. This restriction is called the same-origin policy. The same-origin policy prevents a malicious site from reading sensitive data from another site. Sometimes, you might want to allow other sites to make cross-origin requests to your app. Example Below  


public void ConfigureAuthentication(IServiceCollection services)

        {

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            services.AddCors(options =>

            {

                options.AddPolicy("CorsPolicy",

                    builder => builder

                    .SetIsOriginAllowed((host) => true)

                    .AllowAnyMethod()

                    .AllowAnyHeader()

                    .WithExposedHeaders("Content-Disposition")

                    .AllowCredentials());

            });

                   }

Tuesday, February 4, 2014

Ref and Out

ref object a, out object out specifies that the parameter is an output parameters, i.e. it has no value until it is explicitly set by the method. ref specifies that the value is a reference that has a value, and whose value you can change inside the method.

Tuesday, October 1, 2013

DataTable Rows filter

DataView dv = dsDetail.Tables["Employee"].DefaultView; dv.RowFilter = "Id in(10,2,1,5,6,1)"; DataTable dt = dv.ToTable(); ((Repeater)ctrl).DataSource = dt; ((Repeater)ctrl).DataBind();

Saturday, April 23, 2011

What Happens When a Request Reaches IIS

This is the link for All the details related parsing asp.net page and generating Requst and Response


http://msdn.microsoft.com/en-us/library/ms972974.aspx

Wednesday, April 20, 2011

Disable Browser Back Button using Javascript

head runat="server">
script type="text/javascript" language="javascript">
javascript:window.history.forward(0);
/script>
/head>

Disable Browser Back Button using Javascript

head runat="server">
script type="text/javascript" language="javascript">
javascript:window.history.forward(0);
/script>
/head>

Tuesday, March 22, 2011

Microsoft Enterprises Library

Microsoft Enterprises Library provide API where we dont need to open and close connection and they have sme predefind method .You dont need to create your own method .it has pedefined method for all that things for insert update delete retrieve and some more specific operation...........

You have to download the Entterprise lIbrary first and Add some Dll through AddReferences from a bin folder of Enterprises Library add

using Microsoft.Practices.EnterpriseLibrary.Data.dll
using Microsoft.Practices.EnterpriseLibrary.Common..dll

and Add the classes in code behind

using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;


//Retrieve and Insert value Using Entrprises library

protected void Page_Load(object sender, EventArgs e)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlcommand = "select * from emp";
System.Data.Common.DbCommand dbCommand = db.GetSqlStringCommand(sqlcommand);
using (IDataReader reader = db.ExecuteReader(
dbCommand))
{
Gridview1.DataSource = reader;
Gridview1.DataBind();
}
}
public void save(string name)
{
DatabaseFactory.CreateDatabase().ExecuteNonQuery("inserts12",name);
}
protected void Button1_Click(object sender, EventArgs e)
{
save("subhash");
}

/////////web.config file
inside the ConfigSection
section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data" />

after closing configsection You have to add

/configSections>
dataConfiguration defaultDatabase="Master1"/>

//dataconfiguration same name as the connection string because DatabaseFactory.CreateDatabase(); using for connection

//connection string

add name="Master1" providerName="System.Data.SqlClient" connectionString="Data Source=subhash-9f7eec2;user id=;password=;database=Master;integrated security=sspi;"/>