I have an ASP .NET Core self-hosted project. I am serving up content from a static folder (no problem). It serves up images cross-site without issue (CORS header shows up). However, for some file types, such as JSON, they CORS headers don't show up, and the client site can't see the content. If I rename the file to an unknown type (such as JSONX), it gets served with CORS headers, no problem. How can I get this thing to serve everything with a CORS header?

I have the following CORS policy set up in my Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCors(options =>
        {
            options.AddPolicy("CorsPolicy",
                builder => builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials() );
        });

        // Add framework services.
        services.AddMvc();
    }

And the following is my Configure

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseCors("CorsPolicy");
        loggerFactory.AddConsole(Configuration.GetSection("Logging"));
        loggerFactory.AddDebug();

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        // Static File options, normally would be in-line, but the SFO's file provider is not available at instantiation time
        var sfo = new StaticFileOptions() { ServeUnknownFileTypes = true, DefaultContentType = "application/octet-stream", RequestPath = "/assets"};
        sfo.FileProvider = new PhysicalFileProvider(Program.minervaConfig["ContentPath"]);
        app.UseStaticFiles(sfo);

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

I am writing a test .aspx page to determine whether or not transform is what's needed for another project.

I'm trying to show/hide "divTest" through using the transform CSS style. Here is the code:

            <%@ Page Language="VB" %>
            <%@ Import Namespace="Ionic.Zip" %>
            <%@ Import Namespace="System.IO" %>
            <%@ Import Namespace="System.Web" %>

            <head>
            <style>

            .shown {
              -webkit-transform: translate(0, 0);
                 -ms-transform: translate(0, 0);
                 -moz-transform: translate(0, 0);
                  -ms-transform: translate(0, 0);
                   -o-transform: translate(0, 0);
                      transform: translate(0, 0);    
            }

            .hidden {
              -webkit-transform: translate(-100%, 0);
                 -ms-transform: translate(-100%, 0);
                 -moz-transform: translate(-100%, 0);
                  -ms-transform: translate(-100%, 0);
                   -o-transform: translate(-100%, 0);
                      transform: translate(-100%, 0);    
            }
            </style>
            </head>


            <script runat="server">
                Sub btnShow_Click(sender As Object, e As EventArgs)
                   divTest.Attributes.Add("class", "shown")
                End Sub

                Sub btnHide_Click(sender As Object, e As EventArgs)
                   divTest.Attributes.Add("class", "hidden")
                End Sub
            </script>

            <html>
            <body>
                <form id="form1" runat="server">

                <div id="divTest" runat="server" style="display: block" class="hidden">
                    Sample text in a div.
                </div>

                <div>
                    <asp:Button ID="btnShow" OnClick="btnShow_Click" runat="server" Text="Show"/>
                    <asp:Button ID="btnHide" OnClick="btnHide_Click" runat="server" Text="Hide"/>
                </div>

                </form>
            </body>
            </html>

I know that everything in script and html works already (I tested buttons with adding other test classes on the div in question). Here is a small jsfiddle with the specific CSS styles working: http://jsfiddle.net/6TMcS/165/

Any reason why it isn't working here?

I have an extension method in my ASP.NET MVC app. That extension method looks like this:

public static MvcHtmlString Metric<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression)
{
  var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
  ..
}

I call the above using stuff like the following:

@Html.Metric(m => m.Flag)
@Html.Metric(m => m.TotalCount)

In the above, Flag is a bool? and TotalCount is a int?. My question is, in the Metric method, how can I detect the type of the property I'm using? The reason I need to know, is, I want to do something like the following pseudocode:

var display = "";
if (property is nullable bool)
{
  if (property is null) || (property is false)
  {
    display = "no";
  }
  else
  {
    display = "yes";
  }
}

How do I detect what type of property I'm working with?

Thanks!

For edit method I need to display selected enum value in drop down list. I get the proper value but when I try to display it in drop down list there is always the default one. Namespace for enums: DotNet.Highcharts.Enums is using in view. Contorller:

var chartTypes = (ChartTypes[])Enum.GetValues(typeof(ChartTypes));
            var selectedType = (from chart in Context.VisualRep
                               where chart.QuestionId == question.QuestionId
                               select chart.DefaultChartType).ToList();

            SelectList chartTypesList = new SelectList(chartTypes, selectedType);

            ViewBag.chartTypes = chartTypesList;

View:

 @using DotNet.Highcharts.Enums
 @Html.DropDownList("DefaultChartType", (SelectList)ViewBag.chartTypes)

Select list contains correct values, when I debug I see in selected value the correct one also Items contain all enum types. But the one which is selected value in not shown in drop down as selecte, all the time is the first value from enum as selected. But in another dropdown in same view, this one works fine:

@using Project.Objects.Enum
@Html.EnumDropDownListFor(model => Enum.GetValues(typeof(SomeTypeEnum)))

this one has also using name space. Only one difference is that SomeTypeEnum is in Object folder in solution and the ChartTypes is somewhere else. I also search for this problem related to DotNet high charts but I did not find anything. Also when I try to fill up the drop down same way as the SomeTypeEnum drop down result is the same, still is the first one value selected instead of one which was really selected on create.

I populate a [visitornumber] and [visitorname] into a grid view. The problem is that I need to prevent the user from being able to manually change the visitor number. so my first instinct was to just make it read only. But when I make it read only the @VisitorNumber param becomes null and is rejected by the database. And of course, if its not read only, they can type one in and then all my code and data goes screwy.

How can I prevent them from typing in a code but still populate @VisitorNumber with the number in the value?

Thanks

<%@ Page Title="Register Visitor Portal" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="RegisterVisitorPortal.aspx.cs" Inherits="resident_RegisterVisitorPortal" %>

<script runat="server">



</script>    

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <%--data source object the grid view is tied to--%>
    <asp:SqlDataSource 
        ID="SqlDataSource1" 
        runat="server" 
        ConnectionString="<%$ ConnectionStrings:Warren_SEINDATASYSTEMSConnectionString %>" 
        DeleteCommand="DELETE FROM [RegisteredVisitors] WHERE [PK] = @PK" 
        InsertCommand="INSERT INTO [RegisteredVisitors] ([ResidentName], [ResidentAddress], [VisitorNumber], [VisitorName]) VALUES (@ResidentName, @ResidentAddress, @VisitorNumber, @VisitorName)" 
        SelectCommand="SELECT * FROM [RegisteredVisitors] WHERE ([ResidentName] = @ResidentName)" 
        UpdateCommand="USE [Warren_SEINDATASYSTEMS] declare @i int  = (SELECT ISNULL(MAX([VisitorNumber]),0) + 1 FROM [RegisteredVisitors]) UPDATE [RegisteredVisitors] SET [VisitorNumber] = @VisitorNumber, [VisitorName] = @VisitorName WHERE [PK] = @PK UPDATE RegisteredVisitors SET [VisitorNumber]  = @i , @i = @i WHERE [VisitorNumber] = (SELECT VisitorNumber FROM RegisteredVisitors WHERE VisitorNumber = @VisitorNumber)">
        <DeleteParameters>
            <asp:Parameter Name="PK" Type="Int64" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ResidentName" Type="String" />
            <asp:Parameter Name="ResidentAddress" Type="String" />
            <asp:Parameter Name="VisitorNumber" Type="Int32" />
            <asp:Parameter Name="VisitorName" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="Label1" Name="ResidentName" PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ResidentName" Type="String" />
            <asp:Parameter Name="ResidentAddress" Type="String" />
            <asp:Parameter Name="VisitorNumber" Type="Int32" />
            <asp:Parameter Name="VisitorName" Type="String" />
            <asp:Parameter Name="PK" Type="Int64" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <%--grid view showing and allowing edit of data--%>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" DataKeyNames="PK">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="PK" HeaderText="PK" InsertVisible="False" ReadOnly="True" SortExpression="PK" Visible="False" />
            <asp:BoundField DataField="ResidentName" HeaderText="ResidentName" SortExpression="ResidentName" Visible="False" />
            <asp:BoundField DataField="ResidentAddress" HeaderText="ResidentAddress" SortExpression="ResidentAddress" Visible="False" />
            <asp:BoundField DataField="VisitorNumber" HeaderText="VisitorNumber" SortExpression="VisitorNumber" />
            <asp:BoundField DataField="VisitorName" HeaderText="VisitorName" SortExpression="VisitorName" />
        </Columns>
        <EditRowStyle BackColor="#999999" BorderColor="Black" BorderWidth="1px" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>



    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>



</asp:Content>

i have a dropdownlist with optgroup.

<select id="myselect"><optgroup label="country">
<option label="albania">Albania</option>
<option label="america">America</option>

<select id="myselect"><optgroup label="state">
<option label="washington">Washington</option>
<option label="texas">Texas</option>

I would like to retrieve the option label from a database.

I am using an AmazonWebServices S3 bucket to upload images in an ASP.NET web application. The thing is that sometimes I get a null object exception while uploading an image. In the code snippet bellow you can see how it is done:

using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(GlobalValues.ACCESS_KEY_S3_BUCKET,
                    GlobalValues.SECRET_KEY_S3_BUCKET, Amazon.RegionEndpoint.USWest2))
                {
                    PutObjectRequest request = new PutObjectRequest();
                    request.InputStream = file.InputStream;
                    request.BucketName = GlobalValues.BUCKET_NAME;
                    request.CannedACL = S3CannedACL.PublicRead;
                    request.Key = "Images/image.jpg";

                    client.PutObject(request);
                }

The line where the exception is thrown is: request.CannedACL = S3CannedACL.PublicRead;

I have been trying to solve it for several hours but I cannot reach a solution. Has anyone experienced something similar? Most of the times it fails when I have a session running in the ASP.NET app for several minutes. Any suggestions? Maybe it is due to a temporary failure in the S3 bucket?

Thanks in advance.

Hi there i am keeping to getting this massege despite my app id is correct.

Here is my function:

 public void AuthorizeInsights()
    {
        string app_id = "my_app_id(client_id)";
        string app_secret = "my_app_secret";
        string scope = "public_profile,email,user_hometown,user_about_me,user_likes,ads_management";

        if (Request["code"] == null)
        {
            Response.Redirect(string.Format(
                "https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
                app_id, Request.Url.AbsoluteUri, scope));
        }

In my facebook developers account page i see that my app id is correct and also the one i am inserting in the code.

Does someone has clue whats going on ?

My asp.net application is giving me a bad request while browsing it using ipaddress, servername or machine name. it is also not working using localhost directly .But if I am browsing website from iis it will work fine.

I have an asp.net core deployed to azure, and I am trying to configure logging to my application using the Microsoft.Extentions.Logging interfaces.

currently my app is writing the logs to Log Files folder in the web app storage.

enter image description here

This seems like the right place to log my changes. However, I want to view these logs in a normal interface - downloading a text file everytime, is kinda annoying.

I have looked into application insights, and azure diagnostic logs, but none of them suggest how to work with it using the ILogger interface.

Good day, fellas. As I was starting my project in Visual Studio Community 2015, I always ended up in seeing an error which says, "Unrecognized tag prefix or device filter 'asp'" in all of the tools that I drag and drop on my project. Any help and solution is very much appreciated..

We are having a problem transitioning from AD FS 2.0 to AD FS 3.0.

We have an ASP.NET MVC application which uses federated authentication through AD FS. In our test environment we have Thinktecture Identityserver 2 configured as a claims provider in AD FS. The application requests authenticationType="urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI". For reference, here is the entire identity section of our web.config file:

  <system.identityModel>
    <identityConfiguration>
      <claimsAuthenticationManager type="ProjectName.Authorization.AuthenticationManager, ProjectName" />
      <claimsAuthorizationManager type="ProjectName.Authorization.AuthorizationManager,ProjectName" />
      <audienceUris>
        <add value="https://applicationdomain/" />
      </audienceUris>
      <securityTokenHandlers>
        <securityTokenHandlerConfiguration saveBootstrapContext="true">
          <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <trustedIssuers>
              <add thumbprint="(thumbprint of ADFS certificate)" name="ADFS Test" />
            </trustedIssuers>
          </issuerNameRegistry>
        </securityTokenHandlerConfiguration>
      </securityTokenHandlers>
    </identityConfiguration>
  </system.identityModel>
  <system.identityModel.services>
    <federationConfiguration>
      <wsFederation freshness="120" passiveRedirectEnabled="true" issuer="https://adfsdomain/adfs/ls" realm="https://applicationdomain/" requireHttps="true" authenticationType="urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI" />
      <serviceCertificate>
        <certificateReference findValue="(thumbprint of application's certificate)" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
      </serviceCertificate>
      <cookieHandler requireSsl="true" />
    </federationConfiguration>
  </system.identityModel.services>

We are currently running on somewhat outdated servers with Windows Server 2008 R2 and AD FS 2.0, but it works. We have recently set up a new environment of servers running Windows Server 2012 R2 and AD FS 3.0. We have installed our MVC application on a new server, and set up AD FS 3.0 on another, configured like the old AD FS 2.0 (as far as we can tell) with the MVC app as a relying party and Thinktecture Identityserver 2 as a claims provider. One difference is that we are now using an AD FS Proxy on a separate server, since AD FS 3.0 requires this (whereas AD FS 2.0 did not). In fact we have two AD FS servers, and then two proxies behind a load balancer. Thinktecture Identityserver 2 is still running on an old server (on Windows Server 2008 R2).

Here is the problem: I browse to the application's address. I get redirected to AD FS as expected, which promptly redirects me to Thinktecture Identityserver 2. So far so good. I log in with a user name ("Anders") and password and get redirected back to AD FS. Here I get a general error page saying "An error occured". In the event log on the AD FS server (the load balancer apparently always directs me to the same node, which happens to be the primary) I find two errors and one warning. First error:

Event 197, AD FS

The Federation Service could not satisfy a token request because the 
accompanying credentials do not meet the authentication type requirement of 
'urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI' for the relying party 
'https://applicationdomain.no'.
Authentication type:
Desired authentication type(s): urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI
Relying party: https://applicationdomain.no 

This request failed.

Then the warning:

Event 1000, AD FS

An error occurred during processing of a token request. The data in this event 
may have the identity of the caller (application) that made this request. The 
data includes an Activity ID that you can cross-reference to error or warning 
events to help diagnose the problem that caused this error.  

Additional Data 

Caller:  Anders

OnBehalfOf user:

ActAs user:

Target Relying Party:  https://applicationdomain.no

Then the second error:

Event 364, AD FS

Encountered error during federation passive request. 

Additional Data 

Protocol Name: 
wsfed 

Relying Party: 


Exception details: 
Microsoft.IdentityServer.Service.Policy.PolicyServer.Engine.InvalidAuthenticationTypePolicyException: Exception of type 'Microsoft.IdentityServer.Service.Policy.PolicyServer.Engine.InvalidAuthenticationTypePolicyException' was thrown.
   at Microsoft.IdentityModel.Threading.AsyncResult.End(IAsyncResult result)
   at Microsoft.IdentityModel.Threading.TypedAsyncResult`1.End(IAsyncResult result)
   at Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.EndIssue(IAsyncResult result)
   at Microsoft.IdentityServer.Web.WSTrust.SecurityTokenServiceManager.Issue(RequestSecurityToken request, IList`1& identityClaimSet)
   at Microsoft.IdentityServer.Web.Protocols.PassiveProtocolHandler.SubmitRequest(MSISRequestSecurityToken request, IList`1& identityClaimCollection)
   at Microsoft.IdentityServer.Web.Protocols.PassiveProtocolHandler.RequestBearerToken(MSISRequestSecurityToken signInRequest, Uri& replyTo, IList`1& identityClaimCollection)
   at Microsoft.IdentityServer.Web.Protocols.WSFederation.WSFederationProtocolHandler.RequestBearerToken(MSISSignInRequestMessage signInRequest, SecurityTokenElement onBehalfOf, SecurityToken primaryAuthToken, SecurityToken deviceSecurityToken, String desiredTokenType, WrappedHttpListenerContext httpContext, Boolean isKmsiRequested, Boolean isApplicationProxyTokenRequired, MSISSession& session)
   at Microsoft.IdentityServer.Web.Protocols.WSFederation.WSFederationProtocolHandler.BuildSignInResponseCoreWithSerializedToken(MSISSignInRequestMessage wsFederationPassiveRequest, WrappedHttpListenerContext context, SecurityTokenElement signOnTokenElement, Boolean isKmsiRequested, Boolean isApplicationProxyTokenRequired)
   at Microsoft.IdentityServer.Web.Protocols.WSFederation.WSFederationProtocolHandler.SendSignInResponseForSecurityToken(GenericProtocolRequest originalRequest, SecurityTokenElement requestedTokenElement, ProtocolContext context)
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.ProcessProtocolRequest(ProtocolContext protocolContext, PassiveProtocolHandler protocolHandler)
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext context)

I have read about supported SAML Authentication types in AD FS on this page: https://msdn.microsoft.com/en-us/library/hh599318.aspx. SmartcardPKI is not listed here. (Though note that the documentation is for AD FS 2.0.)

On the AD FS servers (both the old and the new) I have tried listing the supported AuthenticationTypes using the following PowerShell command:

get-adfsproperties | select-object -expandProperty AuthenticationContextOrder | select-object -Property AbsoluteUri

Both on the old server and the new this outputs:

urn:oasis:names:tc:SAML:2.0:ac:classes:Password urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport urn:oasis:names:tc:SAML:2.0:ac:classes:TLSClient urn:oasis:names:tc:SAML:2.0:ac:classes:X509 urn:federation:authentication:windows urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos

No SmartcardPKI here either. Never the less it works in the old environment.

I also tried using PasswordProtectedTransport in place of SmartcardPKI (by editing the MVC application's web.config). The result was exactly the same, except that the first error message now said:

The Federation Service could not satisfy a token request because the 
accompanying credentials do not meet the authentication type requirement of  
'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport' for the  
relying party 'https://applicationdomain.no'...

Any pointers as to what I should try next would be very welcome. Maybe there are differences between AD FS 2.0 and 3.0 which require me to make configuration changes to Thinktecture IdentityServer 2?

how to move or copy the csv file to Azure storage using Azure Event Hub from onpremises in C#.. can any one give me sample code so that it will be very helpful for me to proceed my work

Is the code below implementing the secure way to retrieve the data from database? help me please, I don't understand about SQL Injection. Someone told me this code can easily get injected. If yes, can somebody explain it? Thank you.

public int CheckIDVisitor(string column, string table, string wheres)
    {
        int i = 0;
        sqlcon = ConnectToMain();
        string sqlquery = "SELECT "+column+" FROM "+table+" "+wheres+"";
        using (sqlcon)
        {
            sqlcon.Open();
            SqlCommand sqlcom = new SqlCommand(sqlquery, sqlcon);
            using (sqlcom)
            {
                SqlDataReader dr = sqlcom.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    i = dr.GetInt32(0);
                }
                else
                {
                    i = 0;
                }
            }
            sqlcon.Close();
        }
        return i;
    }

For edit method I need to display selected enum value in drop down list. I get the proper value but when I try to display it in drop down list there is always the default one. Namespace for enums: DotNet.Highcharts.Enums is using in view. Contorller:

var chartTypes = (ChartTypes[])Enum.GetValues(typeof(ChartTypes));
            var selectedType = (from chart in Context.VisualRep
                               where chart.QuestionId == question.QuestionId
                               select chart.DefaultChartType).ToList();

            SelectList chartTypesList = new SelectList(chartTypes, selectedType);

            ViewBag.chartTypes = chartTypesList;

View:

 @using DotNet.Highcharts.Enums
 @Html.DropDownList("DefaultChartType", (SelectList)ViewBag.chartTypes)

Select list contains correct values, when I debug I see in selected value the correct one also Items contain all enum types. But the one which is selected value in not shown in drop down as selecte, all the time is the first value from enum as selected. But in another dropdown in same view, this one works fine:

@using Project.Objects.Enum
@Html.EnumDropDownListFor(model => Enum.GetValues(typeof(SomeTypeEnum)))

this one has also using name space. Only one difference is that SomeTypeEnum is in Object folder in solution and the ChartTypes is somewhere else. I also search for this problem related to DotNet high charts but I did not find anything. Also when I try to fill up the drop down same way as the SomeTypeEnum drop down result is the same, still is the first one value selected instead of one which was really selected on create.

I have a website which developed by using asp.net, (DB is MYSQL) and hosted as test.lk Currently it serves as a forum website. Also I made a classified website. So I decided to serve these two sites with subdomains instead of taking another domain.

So forum site will available at

forum.test.lk

and classified site will avaliable at

classified.test.lk

So since both sites refer the same domain I want to manage one user account for both sites. Remember both sites have two different DBs. but user tables have same schema.

So If a user create login in test.lk that should have the ability to use the both sites with same account. SO what is the best way to do this?

I thought separate user table and put it in another database. So this DB will contain only one table. And also registration page will be available at www.test.lk

If user goes to forum site in there there is a login page, same goes with classified website. So if a user logged from forum site and If he didn't logged at classified site he have to log to the classified site again. but there is only one registration page. SO am I doing this right? How about the user sessions?

I have a Gridview with some data added from database. So what I want is, I want to HIDE the button if the value in the amount column is 0 or NULL

I tried on RowDataBound like below

 if (e.Row.Cells[10].Text == "0")
    {
        e.Row.Cells[15].Style["display"] = "none";
    }

But it was telling that column is ""

So how can I hide the button if the value is 0

I have been tasked with migrating a website that was on our iis web server to Go Daddy. I am unfamiliar with asp.net an have a couple questions about migrating this site.

Included in the site files is a file called web.config with some connections strings.

   <?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

Followed by some security account. All the files for the site are straight HTML, jquery and css type stuff, except for a contact form that seems to be connected the database. My question is how likely is that this site will be easy to migrate. It runs on my local machine fine, except for the contact page.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Contact.aspx.cs" Inherits="Ellis.Website.Contact" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="IE=8" http-equiv="X-UA-Compatible" />
<title></title>

<!-- CSS -->
<link rel="stylesheet" href="css/reset.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
<!-- This is where you choose your color scheme - Just change the stylesheet name to the color you want. -->
<link rel="stylesheet" href="css/orange.css" type="text/css" />
<!-- You can choose from the following: red, orange, green, blue and violet. -->
<link rel="stylesheet" href="css/superfish.css" type="text/css" />
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.7.3.custom.css" />
<link rel="stylesheet" href="css/coin-slider-styles.css" type="text/css" />

<!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="css/ie7.css">
<![endif]-->

<!-- Scripts -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="js/jquery.easing.js"></script>
<script type="text/javascript" src="js/jqFancyTransitions.js"></script>
<script type="text/javascript" src="js/coin-slider.js"></script>
<script type="text/javascript" src="js/ui.core.min.js"></script>
<script type="text/javascript" src="js/ui.tabs.min.js"></script>
<script type="text/javascript" src="js/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/Delicious.font.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/bluz.js"></script>
</head>
<body id="sub-page">
    <form id="form1" runat="server">
    <!-- site-wrapper START here -->
<div id="site-wrapper">
  <!-- header START here -->
  <div id="header">
    <!-- container START here -->
    <div class="container">
      <!-- top START here -->
      <div id="top">
        <!-- logo START here -->
        <div id="logo">
          <h1><a href="index.html"><img src="images/logo.png" alt="Ellis Storage" /></a></h1>
        </div>
        <!-- logo END here -->
        <!-- main-nav START here -->
                <div id="main-nav">
          <ul class="sf-menu">
            <li><a href="index.html">Home</a>

            </li>
              <li><a href="locations.html">Locations</a>

            </li>

              <li><a href="staff.html">Staff</a>

            </li>

            <li><a href="tips.html">Moving Tips</a>

            </li>

            <li><a href="supplies.html">Moving Suppies</a>

            </li>

            <li class="current_page_item"><a href="contact.aspx">Contact</a></li>
          </ul>
        </div>
        <!-- main-nav END here -->
      </div>
      <!-- top END here -->
      <div id="pagename">
        <h2><span>Contact Us</span></h2>
        <p class="tagline">When ever, where ever...</p>
      </div>
    </div>
    <!-- container END here -->
  </div>
  <!-- header END here -->
  ""            ""

I would like advice on using an API, in my asp.net 5 (MVC 6) project..

The API I would like to consume can be accessed something like..

https://api-sandbox.nicedata.com/hi/genre/getGenreDetails
?apiKey={your-api-key}
&GenreID=123456 

but sometimes I may need to use different api methods for example ..

https://api-sandbox.nicedata.com/hi/search/searchGenres
?apiKey={your-api-key}
&IsFast=true
&IsLive=true
&ClassIDs=1
&PreferenceIDs=1,34,45

Please let me know how one would go about this in asp.net 5 ..

I have a javaScript file providing dynamic tabs with jQuery that works just fine on its own:

SpecificationAndAvailabilityTabs.js

var height;

//Have the specifications tab open by default.
$(document).ready(function () {
    $('.tabs #defaultOpen').addClass('active');
    $('.tabs #Overview').show();
    height = $('.tabs #Overview').height();
});

function openTab(evt, tabName) {
    var i, tabcontent, tablinks;

    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }

    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active",     "");
    }

    document.getElementById(tabName).style.display = "block";
    $('.tabs #' + tabName).height(height);//Give the Availability content      area the same height as given to the Specification content area.
    evt.currentTarget.className += " active";
}

Now I am trying to introduce a second file in the same directory, right now I am just trying to execute some very basic manipulation to see if it works but it does not:

AvailabilityIcons.js

$(document).ready(function () {
    $("button").click(function () {
        $("p").hide();
    });
});

And here are the scripts being added to the View in my ASP.NET application:

...
//Script for tab toggle functionality
Html.AppendScriptParts("~/Themes/WCA/Scripts/SpecificationAndAvailabilityTabs.js");
//Script for Dynamic Availability Icons
Html.AppendScriptParts("~/Themes/WCA/Scripts/AvailabilityIcons.js");
...

Now the problem does not even occur with the second file itself, but for some reason it causes all references to '$' in all javaScript files to go unrecognized: enter image description here

From my research I keep running into the common solutions of avoiding conflicts with both

(function($) {
    /*My Code*/
}(jQuery);

as well as using:

jQuery.noConflict();

But no combination of these two solutions on both of the files above has managed to resolve anything for me. I will note again that the first file works 100% if I take away the second "AppendScriptParts". Any help is much appreciated.

I am trying to access a string from code behind into javascript in aspx page

code behind

  protected void btnSearch_Click(object sender, EventArgs e)
        {            
            List<string> imageList = new List<string>();
            string images="";
            imageList = GetMatchingImages(@"C:\Users\Shahzad\Documents\Visual Studio 2013\Projects\ImageSearchEngine\ImageSearchEngine\Images", txtSearch.Text);

            foreach (var image in imageList)
            {
                images += "\"" + image + "\",";
            }
            images ="["+ images.Substring(0, images.Length - 1)+"]";

        }

        public List<string> GetMatchingImages(string path, string keyword)
        {
            var matches = new List<string>();

            var images = System.IO.Directory.GetFiles(path);

            foreach (var image in images)
            {
                if (image.Contains(keyword))
                {
                    matches.Add(image);
                }
            }

            return matches;
        }

and in the aspx page

<script type="text/javascript">
     var imagesList;
     function getImages()
     {
         return <%=images%>;
     }
     imagesList = getImages();
 </script>

but it is giving error 'images is out of this context' plz help me find out where I am making the mistake