ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a Asp.net MVC app which sends a float array data to the client

float[320,240]
See attached for the data, its around 1.4mb

I need to dramatically reduce this size, and be able to convert it to the current format in Javascript

Here is the request
 $.ajax({
  type: "POST",
  url: "@Url.Action("CameraChange", "Home")",
  async:true,
  data: "{'cameraId':'" + ID + "'}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (response) {
                 imageTemperatureDataArray = JSON.parse(response.TemperatureDataArray);
  },
   error: function (e) {
       alert("error: " + e.message + ' ');
  }
 });

Open in new window


Then I use it futher down in
 
  $("img#schemesImageSchemes").mousemove(function (e) {
       $('#dataSchemes').text(imageTemperatureDataArray[myX][myY]);
});

Open in new window


Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
0
OWASP: Avoiding Hacker Tricks
LVL 13
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

I’m creating a asp.net core application.

Anyone know a good shared hosting ?

Anyone use godaddy windows shared hosting plan to deploy a asp.net core website?
0
Is there a way to force a Control+F5 on a user? We publish our code and the style sheets look horrible until they do a control+F5, but other than putting a message on the screen, how do we trigger the style sheets to update?

thanks!
0
We need to convert part of our MS Access DB to a web app.  ASPX or .net.  No experience in web apps.  Ideas?
0
Hi

I am using the following VB.net code in creating an ASP.net chart
        Dim series4 As New Series()
        series4.Name = "Series 4"
        series4.ChartType = SeriesChartType.Line
        series4.Color = Drawing.Color.Green
        series4.BorderWidth = 2
        series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.LegendText = "Day Work Rate"
  ChartData.Series.Add(series4)

Open in new window


I want to flip the axes of the chart. Should I just use

 series4.XValueMember = " series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.YValueMembers = "Date"
        series4.LegendText = "Date"

Open in new window

0
I want to post a MP3 file on my asp.net website.  I am using vb.net.   When the user clicks on the file I need it to play.  One option I tried was to just put a hyperlink to the file.  On edge and chrome it works fine but in IE it asks to download or run.   I need the file to play without asking to download or run.    Any help would be appreciated.

thank you
0
Hi,

I have a question. I have a existing WCF type framework that has like 8 difference .svc's and in each one of those .svc's there are like 40 different web services (methods) that are called.  This is in ASP.NET and C#.

I am going to start implementing REST aspects as well with ASP.NET and C#.

Is it wise to maintain 2 separate frameworks? One for REST methods (could also be 10-20 different methods) and that over existing SOAP svc's? Or do I combine the REST calls/process into the existing WCF?

If the suggestion is 2 separate frameworks... does anybody have an example of how that would be done in REST?

Any information would be greatly appreciated.

Thanks!
0
I'm looking for a bit of hand-holding on setting up, what I thought would be a simple project.
I am using Visual Studio 2017 .Net 4.7.
I've done some coding in c# long ago, but am more comfortable in vb.net.
I had previously done quite a bit of winform development, and only ever dabbled in web dev.  Since it's been so incredibly long ago, I would like to have some guidance on starting this from scratch.

I plan to have multiple progression questions on this and I'll attempt to keep it limited to simple steps throughout.
For the first question on this, however, I need to describe what I'm envisioning:

I will have a user visit this single web page. There would be a title with a button/link to click for more info (detailed instructions located elsewhere in our intranet).
Page load would read a sql database to pull down a list of memberships for this specific user (I do have the working code to accomplish this).
Those results are then placed into a list box (I thought a checkedlistbox would be best).  

The user is then given the following options:
A button, always available, to CREATE.
A button, only available if one, and only one item is selected, to MODIFY.
A button only available if one or more items are selected.  This button should present a confirmation, since this would be a delete process to occur.

I'd like to use bootstrap because I did spend a bit of time learning a bit about it, but I have very little knowledge on how to implement it into my code.
0
Using Framework...
     ASP.NET Regular Web Form

Using Code Behind...
     VB.net & JavaScript & JQuery

My Issue...
I Need VB.code replacement for the following JavaScript Function --
(JavaScript Function may not be Syntactically Correct Since I Slightly modified its structure)
function myFunc(RBG) {
   var rbGrp = RBG; 
   var myVal;
   var radioButtons = document.getElementsByName(rbGrp);
      for (var x = 0; x < radioButtons.length; x ++) {
        if (radioButtons[x].checked) {
	     myVal = radioButtons[x].id);
             return myVal;
        }
      }
    }

Open in new window


This JavaScript Function is PASSED the GROUPNAME of a group of Radio buttons...

It loops thru all the individual radio buttons of that Group of buttons via that GROUPNAME...

and ihen it should return the one radio button that was selected...

I need this in Server Side vb.net code instead of client side JavaScript code...

I have already laid out 35 Groups of Radio buttons each with 2, 3 or 5 individual choices -- already built in my ASP.net form so doing Radio Button List is now past as option

Any Experts have or can create this vb.net code equal to the JS code ??

thanks... CJ
0
In the past I have developed applications using C#, ASP.Net Web Forms, Asp.Net MVC 5 , Razor , javascript, css, bootstrap, Entity Framework and SQL Server.
I'm familiar with ASP.NET MVC model.

Now i'm looking at upgrading my skills to ASP.NET Core.

I saw this book.

https://www.amazon.com/Front-end-Development-ASP-NET-Angular-Bootstrap/dp/1119181313/ref=sr_1_4?keywords=asp.net+core+angular&qid=1557595000&s=books&sr=1-4


Which led me to think the following.

If I'm going to create a ASP.NET Core MVC application using Entity Framework with a Sql Server back end....

What is the advantage of bringing in Angular into the mix?

What is the advantage of using Angular + ASP.NetCore MVC + Razor + JavaScript + CSS + Bootstrap + C# + Sql Server?

Rather than just this ASP.NetCore MVC + Razor + JavaScript + CSS + Bootstrap + C# + Sql Server?
0
Fundamentals of JavaScript
LVL 13
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Need simple JavaScript Solution to Put Same ASP.net text box text values into another ASP.net textbox on the same form and same page...

I have this working in asp.net runat with vb.net code and onkeypress call code BUT the postback re-positioning is irritating including trying to suppress it with maintain...

JScript should cause no post back i assume and be quite easy ?

<%@ Page Language="VB" AutoEventWireup="false" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data"%>\
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.data.OleDb" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Private Sub MyTextBox_TextChanged(sender As Object, e As EventArgs) Handles MyTextBox.TextChanged
        AddTextBox.Text = MyTextBox.Text
    End Sub
</script>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body> 
  <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="MyTextBox" runat="server" onkeypress="AddTextBox_TextChanged" AutoPostBack="true"></asp:TextBox>
        <asp:TextBox ID="AddTextBox" runat="server" Enabled="False" ReadOnly="True"></asp:TextBox>
    </div>    
  </form>
</body>
</html>

Open in new window

0
In my ASP.net home page I declare the two following variables at the top of the Default.aspx.vb page
I then load data to a grid using the next piece of code. My intention is to be able to sort the data by clicking
on the column header so I included the  GridView1_Sorting procedure shown further down at the bottom.
When I click on a header I get the following error in that procedure "DataTable must be set prior to using dataview."
Public Class Default
    Private objDV As New DataView
    Private dt As New DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Open in new window


    Sub Bind_Grid_to_Dataview(ByVal oGridView As GridView, ByVal oSQL As String)

        Try

            Dim cs As String = ConfigurationManager.ConnectionStrings("SSQL").ConnectionString
            Dim objCon As New SqlConnection 'Declaring connection object
            objCon.ConnectionString = cs
            'opening connection
            If objCon.State = ConnectionState.Closed Then
                objCon.Open()
            End If
            'declaring new Data Adapter
            Dim objDA As New SqlDataAdapter
            objDA.SelectCommand = New SqlCommand(oSQL, objCon)
            Dim objDS As New DataSet
            objDA.Fill(objDS)
            Call oCheck_DataSet_For_Blank_Columns(objDS)
            'Below i am creating a default view of the Data Set
            objDV = objDS.Tables(0).DefaultView
            oGridView.DataSource = objDV
            oGridView.DataBind()

        Catch ex As Exception
            Response.Write(ex.Message & " dr2")
        End Try
    End Sub

Open in new window


   Private Sub GridView1_Sorting(sender As Object, e As GridViewSortEventArgs) Handles GridView1.Sorting

        Try
            objDV.Sort = e.SortExpression
            GridView1.DataSource = objDV
            GridView1.DataBind()
        Catch ex As Exception
            Response.Write(ex.Message & " Gridview Sorting Error 4")
        End Try

    End Sub

Open in new window

0
Installed SQL Server EXPRESS 2014 to my local desktop -
Name: MY64BIT-PC\SQLEXPRESS

Created SQL Server AUTH hybrid login

Created a User Name and Password for connection string and gave them every permission i could find for both Server and Database I created

Created New DBase
Name: HousingAuthority

Created a table
Name: dbo.tblApplication

See uploaded image file with these names...

with 4 fields ID, FirstName_1, LastName_1, datetime field

See web page code below... that runs on visual studio local host server (needs better web config error handling too)

Insert Into code fired from button not working and web page not showing error...

<%@ Page Language="VB" AutoEventWireup="false" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data"%>\
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.data.OleDb" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Private Sub SubmitEM_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim con As New SqlConnection : Dim cmd As New SqlCommand
        Try
            con.ConnectionString = "Data Source=MY64BIT-PC\SQLEXPRESS;Initial Catalog=HousingAuthority;Persist Security Info=True;User ID=ABC;Password=XYZ"
            con.Open()
            cmd.Connection = 

Open in new window

0
I have a simple web site - and that's all it will really become - where I am displaying a list of items owned by the current logged on user.
I most of it all working in my very basic asp.net skills, but it's blah.

What options might I have to make it look more professional?
At this moment, it's simply a checkedlistbox, a few buttons and a couple of labels.  
I realize the answer may have loads to do with CSS.  I'm inside a corporate network so I may have limited options outside of what's natively available.

Just looking for some advice on this one...
0
I have a button to delete checked items in a list.
I want to display a confirmation prompt before continuing with the delete routine.
I'm not certain how to do this.
I've tried with some code I found online that has a javascript function in the aspx code, but it doesn't seem to process that script.
0
I need to use HTML encode to filter/scrub some data being read by my SqlDataReader object. Trying to prevent an XSS attack. I've never used HTML encode before but I need to apply it to code that looks like the following:

                        oReader = oCmd.ExecuteReader();

                    if (oReader.HasRows == true)
                    {
                        int iLastID = 0;
                        decimal total = 0;

                        while (oReader.Read())
                        {
                            if (iLastID != oReader.GetInt32(oReader.GetOrdinal("checktypeid_fk")))
                            {	                            
                                sTableDetail += "<tr>";
                                sTableDetail += "<TD>" + oReader.GetValue(oReader.GetOrdinal("Description")).ToString() + "</TD>";
                                sTableDetail += "<TD>" + oReader.GetValue(oReader.GetOrdinal("Quantity")).ToString() + "</TD>";
                                sTableDetail += "<TD align=right>$" + oReader.GetValue(oReader.GetOrdinal("Amount")).ToString() + "</TD>";
                                sTableDetail += "<TD align=right>$" + Convert.ToString(Convert.ToDouble(oReader.GetValue(oReader.GetOrdinal("Amount"))) * Convert.ToDouble(oReader.GetValue(oReader.GetOrdinal("Quantity")))) + "</TD></TR>";
                            }
                            else
                            {
                                

Open in new window

0
I have an ASP.NET MVC application built database first and Entity Framework.
The Sql Server database has a table named Applicant that has a foreign key to a reference table called ApplicantType_Ref.
When I create the scaffolding, the resulting model, Applicants.cs has the foreign key, ApplicantTypeId as a property:
public int? ApplicantTypeId { get; set; }

Open in new window

When I run the application and create a new applicant, the resulting view shows me, as expected, a drop down for the Applicant Type Id.
What I need to see instead is a drop down for the Applicant Type in the same row of the table as the Applicant Type Id.
How do I do that?
Do I change something in the Applicant.cs model before creating the controller?
I do see a property for the ApplicantType_Ref table itself:
public ApplicantTypeRef ApplicantType { get; set; }

Open in new window

Do I use that property in the view or the controller, replacing the other property, ?
In other words, how do I get the drop down box to show the actual applicant type instead of the list of ApplicantTypeId primary keys?
0
On page load, I'm going to grab details of a user's assignments, based on the user coming to the site.
I'm going to populate a checkedlistbox with just a reference ID and associated title.

However, when they click on an item, I want to show the further details based upon that reference ID.

Originally I was going to create a list, and add reference to all of the details there, but I believe that maybe cookies might serve me better here - although I'm not very familiar how to use them properly.

Can someone provide some guidance?
I'd love to have some ability to search a cached table based on the ID selected, and retrieve the details that way, rather than making another call to the databse.
0
I'm creating a simple form in asp.net.
On page load, I want to display the user's name (I'll get to that later if I can't figure it out )
Next I want to retrieve a list of elements from a SQL table that belong to this user.
If there are any results returned, I want to get a total and display a label that says "You have X items" and then show a checked listbox with the items.
If there are no results, no list would be displayed and a message stating that they have no items.

I can handle the  logic for displaying everything, but it's been so terribly long since I've done any development in asp.net, that I don't really know where to begin to make that SQL connection and pull back results.
I would need to pass credentials because the user's account won't have permissions to read the data.
But the table layout will have a field called Owner that would be equivalent to their user ID that I'm returning from the windows login identity.

If someone could help me get started, I think I can carry this on to completion, as presumably it will come back to me... (I hope)
0
Why Diversity in Tech Matters
LVL 13
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

I've created an Asp.Net core MVC application, database first. .NETCore.App (2.1).
It is the first MVC Core app that I've created.
When I run the application with IIS Express, it loads in the browser correctly.
https://localhost:44312/
Then I create a controller called ApplicantsController.
When I try to navigate to,
https://localhost:44312/Applicants
I get the following error:
InvalidOperationException: Unable to resolve service for type 'SalaryCalculator.Models.Salary_CalculatorContext' while attempting to activate 'SalaryCalculator.Controllers.ApplicantsController'.

Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)

Here is the Startup.cs class:

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }      

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
          

Open in new window

0
Access to XMLHttpRequest at 'http://someURL' from origin 'http://someURL' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.


This is a call to a REST API controller action method. I enabled CORS on the top of controller like below:
[EnableCors(origins: "*", headers: "*", methods: "*")]
 public class TestController : ApiController
    {
    }

Open in new window


Also in the web.config:

<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Credentials" value="true" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
        <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE" />
		<add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>

Open in new window


Any ideas please thanks.
1
Hi,
I always developed in windows forms. However now I came up with a litle project for the web. I'm using Devexpress components, however this is still a bit confusing for me. For example, the following link https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/Overview/NetCore/Light/ shows several examples. From what I understand I can choose one of these frameworks presented or even the Asp.Net core, to develop on Api Devexpress. I would like to know if this is correct, and what would be the best choice. For me it might be easier asp.net core, since I am already develop in windows forms.

best regards
0
Change MasterPage depending on URL. Is  this possible.

I have 2 departments at work that both use the same site I built but they want to call it by different names. So when I built it back in 2014 I published it twice with two different titles and different name in the master page. So what I want to do (if possible) is put 2 urls to the same site but depending what url they use will affect the masterpage, eg wether the title will say Dept A or Dept B and change the label at the top of the master page to say Dept A or Dept B, or would it be any easier to just make 2 different Master pages and somehow load a different one depending on url.
I have no idea how to go about this so any ideas are greatly appreciated :)
0
Hi,
I have an ASP.NET MVC Core 2.1.1 project running in Visual Studio 2019.
Since I have already created a database, I want to connect the application to the existing database with database-first development.
From the Visual Studio, Package Manager Console, I put in:

Scaffold-DbContext "server=ServerName;Database=DbName; Trusted_Connection=true; Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

That gives me the following error:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.8-servicing-32085'. Update the tools for the latest features and bug fixes.
Unable to find provider assembly with name server=ServerName. Ensure the specified name is correct and is referenced by the project.

I got the name, ServerName, directly from the Visual Studio connection properties:
Data Source=ServerName; Initial Catalog=DbName; Integrated Security=True

Is there something different I should put for ServerName?
0
In my Web Form, I have a TreeView and a DataGrid. When a user selects a node from the tree, an SQL query retrieves related values from the Database and populates a row in the grid. The user will be selecting multiple nodes, so I need the rows appended to grid, not overwriting previous ones. Also need to be able to delete a row from the grid if the user chooses. I have been cobbling together bits of code from many forums to use session variables, but cant seem to get it to work. As soon as I code anything relating to a session variable the grid stops populating. If I remove the "session stuff" , then the grid works fine, but each row gets overwritten with the next node selection.  My code is below. Thanks in advance for any help. (I am still fairly new to asp.net)

aspx:
 <telerik:RadGrid ID="RadGrid1" runat="server" 
                         
                         AutoGenerateColumns="False"   Skin="Telerik" OnDeleteCommand="RadGrid1_DeleteCommand"  AutoPostBack="true"> 
                        <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
                        <MasterTableView  DataKeyNames="ID" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                        <FooterStyle CssClass="gridFooter"></FooterStyle>
                        <NoRecordsTemplate>
                            Setup / PDI items...
                        </NoRecordsTemplate>
                        <Columns>
                             

Open in new window

0

ASP.NET

125K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications