I have a Windows Forms application written in C# that processes millions of points from a MySQL database. Once the data is processed it plots and charts the data on various graphs.

I was asked to create a web application version of this program instead of Win Forms. Since the Win Forms data processing part is thousands of lines of code, I decided to go for a .NET environment to salvage the c# code instead of rewriting.

Please see program flow below, and questions:

1) User Connects to ASP.NET MVC website
2) User inputs data in html form
3) Using the users form input in step 2, c# program within the same solution is started, data from the html form is passed to the program.
Where? How? Is this all done in the controller?

4) The program generates MySQL Query's based on user input, receives and processes data
5) The program returns large arrays of data back to ASP.NET MVC5
What is the best practice for the way the application return data back to MVC5?

6) ASP.NET MVC5 Plots said data using Html5 Canvas charting API's

EDIT: Just to be clear I am NOT converting my WinForms to ASP.NET, but am simply using the same class libraries which processed the data.

I've set up SignalR Realtime communication for my ASP.NET based website. However, I need to know if it's possible to share the same SignalR Hub with a separate Mobile Backend Project which deals with the same server and database. Basically like accessing the facebook's inbox through web and mobile at the same time?

That would be a ASP.NET Web project and a Mobile Client connected to one hub.

I have some trouble creating an dropdownlist correctly in MVC. I'm not sure how to link the dropdownlist with the model, and create values for it. Right now I have the following code that creates 2x dropdownlists:

<div class="form-group">
        Outward route<br />
        <select class="dropdown" id="Dropdown-outward">
            <option>Copenhagen</option>
            <option>Oslo</option>
            <option>Stockholm</option>
        </select>
    </div>
    <div class="form-group">
        Return route<br />
        <select class="dropdown" id="Dropdown-return">
            <option>Option 1</option>
            <option>Option 2</option>
            <option>Option 3</option>
        </select>
    </div>

I used the select & option command to create values as you see in the code. I know you can use some razor syntax like.

@Html. something

but I can't seem to do it right. Have created an model (Booking) which look like this:

namespace Project.Models
{
public class Booking
{
    public int ID { get; set; }
    public string Departure { get; set; }
    public string Return { get; set; }
    public DateTime DepartureDate { get; set; }
    public DateTime ReturnDate { get; set; }
    public int Adults { get; set; }
    public int Childrens { get; set; }
}
}

If I use the Html helper like this:

@Html.DropDownList( )

What should i write insite the braces? and how do i add values to it, so you can select, lets say the cities Oslo, Copenhagen & Stockholm?

We are using Paypal payflow dll for payment process in our application. We are not storing the buyer card information in our local database for the first time of subscription with our product. We are storing the sale or Authorization transaction id in our database on first time of purchase, based on that we are creating Recurring payment profile on paypal with Billing cycle to renew their subscription automatically.

Based on the recurring payment status, we will do some operation from our application with automated service. The automated service will start @ 12AM, at that tiem we will do inquiry transaction for the recurring payment. If the payment success we will continue otherwise will send transaction failed mail to buyer.

Example, if the buyer purchase the product on August 1, 2015. The subscription will end on August 31, 2015. For the next time subscription we are passing the next payment date is August 31, 2015 to paypal. So the payment will happen on before August 31, 2015 6.00 AM. But the user wants to cancel on August 31 after noon (2.00 PM).

So the amount was taken 18 hours before. In that case we need to refund the amount.

To avaiod this situation, we can plan to get amount from buyer at that time of automated service running (12.00 AM). How can we achive this in paypal without storing buyer card information in local database.

Is there anyway with Recurring payment? Are we able to create profile information on paypal without amount value.

Could please provide suggetion.

I want ASP.NET 5 with EF7 and some old EF 6.1.3 in some subassemblies.

I am upgrading an older web project to ASPNET5, and I am using VS2015.

I have created a plain template demo project and it works as it is on its own.

However, as soon I added some .NET 4.0 with EF 6.1.3 projects to the solution, I got this error

CS1061 'EntityFrameworkServicesBuilder' does not contain a definition for 'AddSqlServer' and no extension method 'AddSqlServer' accepting a first argument of type 'EntityFrameworkServicesBuilder' could be found (are you missing a using directive or an assembly reference?) lic5.DNX 4.5.1 C:\data3\ssc\ssc.master\license\lic5\Startup.cs 55

In the project file, I have

  "dependencies": {
    "EntityFramework.SqlServer": "7.0.0-beta5",
    "EntityFramework.Commands": "7.0.0-beta5",

(Why not upgrade to EF7 everywhere? Then I need to use .NET 4.5, and I have many old .NET 4.0 dlls for which I am not responsible, and which needs to continue to be .NET 4.0.)

As you can see, the code below is static and I want to make it dynamic by fetching data to my database using SQL server - stored procedure via C#. how can I achieve this? can I use JSON? how?

  <script>


    $(function () {

        // create the chart
        $('#container').highcharts('StockChart', {


            rangeSelector: {
                selected: 1
            },

            title: {
                text: 'AAPL Stock Price'
            },
            plotOptions: {
                series: {
                    color: 'red'
                }
            },
            series: [{
                type: 'candlestick',
                name: 'AAPL Stock Price',
                data: [
                    [1422576000000, 4.1000, 4.1000, 4.0100, 4.0800],
                    [1422835200000, 4.0100, 4.8000, 4.0000, 4.2800],
                    [1422921600000, 4.2800, 4.2800, 4.0500, 4.1000],
                    {
                        x: 1147910400000,
                        open: 65.68,
                        close: 66.26,
                        low: 63.12,
                        high: 63.1,
                        color: 'red'
                    }
                ]
            }]
        });
    });
</script>

I am new to Asp.Net. I have a question about a viewstate control. Msdn says that it as a client-side state management but suggest that it can be disabled if there is big data on the page because of performance issues.

So, if this is a client-side state, how does it affect page load time of the site?

In my C# .NET MVC4 application there is an approach of having request/response pairs for each Action.

So, my HomeControllers Index action will have a HomeIndexRequest as parameter and will return a model for the View from type HomeIndexResponse.

public ActionResult Index(HomeIndexRequest req)
{
    var res = DoSomething(req);

    return View(res);
}

All Responses inherit from BaseResponse<T> where T is as ViewModelBase-class.

In my View I can now access the ViewModel via

@Model.ViewModel.SomeValue

Is there any way to use a custom WebViewPage, like

public abstract class MyWebViewPage<TModel, TViewModel> : WebViewPage<TModel> ...

So I can have a get-property

public TViewModel ViewModel { get { return Model.ViewModel; } }

Which can be accessed in each View like @ViewModel?

The problem for me is, that I need the second type-parameter to determine the correct type of the ViewModel.

Is this possible at all or can/must a WebViewPage only have one type-parameter?

I'm trying to fetch the content of the MsWord file and load it into a div tag.

Can anybody tell, How to get the content of a word file with the same alignment.

I'm using Interop.dll

Here is the code,

using Microsoft.Office.Interop.Word;
using System;
using System.Text;

 protected void Page_Load(object sender, EventArgs e)
        {
            // Open a doc file.
            Application application = new Application();
            Document document = application.Documents.Open(@"D:\MyDocument.docx");

            StringBuilder strRdr = new StringBuilder();
            // Loop through all words in the document.
            int count = document.Words.Count;
            for (int i = 1; i <= count; i++)
            {
                strRdr.Append(document.Words[i].Text);
                divContent.InnerHtml =Convert.ToString(strRdr);

            }
            // Close word.
            application.Quit();
        }

It works fine. but it reads only Text. But I would like to fetch the entire content with proper alignment.

Please help me.

Thank You.

am using ASP.Net 4.5 webforms in which I've Ajax TabContainer with 2 TabPanels namely First and Second. In First Tab am having Gridview with firstcolumn as LinkButton, when an user click the LinkButton, I need to pass that LinkButton text to second TabPanel, I searched and tried so many ways, but no gain. Need your support.

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<script type="text/javascript">
    $(document).ready(function () {

        //$('[id$="LinkButton"]').click(function () {
        //    alert('ss');
        //    var customID = $(this).attr('myCustomID');
        //    alert(customID);
        //});


        <%-- function GetName(name) {
            $.ajax({
                type: "POST",
                url: "namesearch.aspx/getByName",
                //data: '{name: "' + $("#<%=txtName.ClientID%>")[0].value + '" }',
                data: '{name: "' + name + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        }--%>
    });
</script>

<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" OnActiveTabChanged="TabContainer1_ActiveTabChanged">
    <ajaxToolkit:TabPanel runat="server" HeaderText="First" ID="TabPanel1">
        <ContentTemplate>
            <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="txtSearch" runat="server" />
            <asp:Button ID="btnSearch" runat="server"
                Text="Search" OnClick="btnSearch_Click" />

            <asp:GridView ID="GridView1" runat="server"
                AutoGenerateColumns="False"
                DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                <Columns>
                    <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server"  myCustomID='<%# Eval("ID")%>'
                                Text='<%#Eval("Name") %>' OnClientClick="SetActiveTab(1)" OnClick="lnkView_Click">
                            </asp:LinkButton>
                               <%-- PostBackUrl='<%#"~/Details.aspx?ID="+Eval("ID")%>'>--%>
                           <%-- myCustomID='<%# Eval("ID")%>' Text='<%# Eval("Name")%>'--%>

                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField DataField="City" HeaderText="City" />
                    <asp:BoundField DataField="Country" HeaderText="Country" />
                </Columns>
            </asp:GridView>

            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT [ID], [Name], [City], [Country] FROM [Location]
                                WHERE ([Name] LIKE '%' + @Name + '%')">
                <SelectParameters>
                    <asp:ControlParameter ControlID="txtSearch" Name="Name"
                        PropertyName="Text" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>

        </ContentTemplate>
             </asp:UpdatePanel>
       </ContentTemplate>
    </ajaxToolkit:TabPanel>

    <ajaxToolkit:TabPanel runat="server" HeaderText="Second" ID="TabPanel2">
        <ContentTemplate>
           <%-- <asp:GridView ID="GridView2" runat="server" 
                DataSourceID="SqlDataSource2">

            </asp:GridView>--%>

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

            <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT [ID], [Name], [City], [Country] FROM [Location]">
            </asp:SqlDataSource>
        </ContentTemplate>
    </ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>



<script type="text/javascript">
    function SetActiveTab(index) {
        var tabContainer = $get('<%=TabContainer1.ClientID%>');
        tabContainer.control.set_activeTabIndex(index);
    }

</script>



</asp:Content>

Let me try to explain this problem in bullet points for a clear understanding

  • I have a Repeater Control which contains a child repeater control (rptChild), a radio buttonList (rblOptions) control and a button (btn) with class (btn btn-info) (along side other nested controls which are not important in this question)
  • Assuming the main repeater has multiple items loaded, when the btn is clicked, the rblOptions and the rptChild of the repeater Item where the button was clicked should be hidden or shown. Not all the rblOptions and rptChilds in the entire main repeater.

I was unable to achieve that with this jQuery code below

$(document).ready(function() {
            $('btn.btn-info').click(function() {
                $("[id*=ChildRepeater]").show();
                $("[id*=rblOptions]").hide();
            })
        })

I have been battling with this all night and unable to make it to work as I want it to. Someone please help.

Please how can we apply a date-picker to a text-box that is not bound to any model field?

For example, I have a 2 text boxes, dt1 & dt2 used to pass a date range to a controller, but the model for the this controller has as no date fields.

My view:

<script type="text/javascript">
    $(function () {
        // This will make every element with the class "date-picker" into a DatePicker element
        $('.date-picker').datepicker();
    })
</script>

<div>
    <h2>Settled Report</h2><br />
    @using (Html.BeginForm("SettledReports", "POSReportController", FormMethod.Get))
    {
        <p>
            Accounts: @Html.DropDownList("accountNumber")
            Start Date: @Html.TextBox("dt1")
            End Date: @Html.TextBox("dt2")

            <input type="submit" value="View Report" />
        </p>
    }
    <h3>Transaction Breakdown</h3><br />
    <table class="table">
        <tr><th>SN</th><th>Card Type</th><th>Trans Count</th><th>Total Gross</th><th>Total Surcharge</th><th>Total Net</th></tr>
        @foreach (var item in Model.summary)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.sn)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.cardType)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.transCount)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.gross)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.surcharge)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.net)
                </td>
            </tr>
        }
    </table>
    <br />
    <table class="table">
        <tr><td>SN</td><td>Merchant</td><td>Trans Date</td><td>Merchant ID</td><td>Terminal ID</td><td>STAN</td><td>Card No.</td><td>Trans Type</td><td>Approval Code</td><td>Gross Amount</td><td>POS Charge</td><td>Net Amount</td><td>Settlement Date</td></tr>
        @foreach (var item in Model.detail)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.sn)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.merchant)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.transDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.merchantID)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.terminalID)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.stan)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.cardNo)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.transType)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.approvalCode)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.gross)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.posCharge)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.net)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.settlementDate)
                </td>
            </tr>
        }
    </table>
</div>

I have a parent view have panel to refresh a partial view. In the partial view, it have a webgrid show data. I want to get all select row in webgrid then get it in parent view as 'selectedlist'. Please, help me! Thanks!

Code - parent view:

@List<Item> tempObject = new List<Item>();
@* Set data for list *@    
<div id="partialViewRefresh">
    @Html.Partial("partialView", tempObject)
</div><!-- End #ContentResultArea -->

I have one main textbox with multiline textmode, and another two textboxes with color textmode, one is to change the text-color and the other one to change the background-color of the main textbox.

The problem is that if I change the background color after changing the text color, the text color will be overridden by black color (I guess this is the default color), or if I change the text color after changing the background color, the background color will be overridden by white color (the default color I guess).

I know the textbox value is posted with PostBack request, but I thought ViewState should store the control information for textbox. It still does not if I enable ViewState for the main textbox explicitly.

Somehow I can fix this problem. But, why does it behave like this?

Here is the main textbox:

    <asp:TextBox ID="txt_Editor"
        TextMode="MultiLine"
        Columns="50" Rows="10"
        EnableViewState="true"
        runat="server"></asp:TextBox>

Here are the two:

    <div class="text-muted">Color Options:</div>
    Text-color:
    <asp:TextBox ID="txt_TextColor" 
        AutoPostBack="true" TextMode="Color"
        Text="#000000" runat="server" OnTextChanged="txt_TextColor_TextChanged">
    </asp:TextBox>

    Background-color:
    <asp:TextBox ID="txt_BackColor"
        TextMode="Color" AutoPostBack="true"
        Text="#FFFFFF" runat="server" OnTextChanged="txt_BackColor_TextChanged"></asp:TextBox>

Here is the related part in the CodeBehind file, whenever a color is chosen the colors of the main textbox should be updated accordingly:

    protected void txt_TextColor_TextChanged(object sender, EventArgs e)
    {
        txt_Editor.ForeColor = Color.FromName(txt_TextColor.Text);
    }

    protected void txt_BackColor_TextChanged(object sender, EventArgs e)
    {
        txt_Editor.BackColor = Color.FromName(txt_BackColor.Text);
    }

I have an out-of-the-box Visual Studio 2013 SPA using WebApi. I added Twitter authentication to Startup.Auth.cs and all of it works just fine when I publish to the root of an IIS web site or when I debug in VS with localhost.

What I can't figure out is how to publish the project to a subfolder like this:

enter image description here

In other words, http://localhost/api

The site itself works. It is the ReturnUrl from Twitter that always redirects to http://localhost/# It includes the correct access_token but in this format:

http://localhost/#access_token=fzgSLjF4W0QAHlhsNFZI...

If I manually type in "api/" before #access_token it opens the default Index page and is authenticated via Twitter. I have tweaked every setting on the Twitter side, javascript, and .cs. I just can't find a solution other than Publish to a root web site. I would like to publish to a subfolder application.

Suggestions?

I'm working on an AdminPortal and I have a database setup as such:

User 1:N UserRole N:1 Role 1:N RolePage N:1 Page

So, a user is connected to a role via the UserRole table, and the role to a specific page via the RolePage table.

I used MVC5 and the Entity Framework to make my Models and Controllers.

In my UsersController I want the Details to show the Roles as well, which it currently does not. From here someone should be able to pick Edit and then add/remove Roles for the specific User.

When I try to use the existing user.UserRoles, as such:

@Html.DisplayNameFor(model => model.UserRoles)

I get an output of:

System.Data.Entity.DynamicProxies.Role_2928XXXXXXXXXXXXX

And I want to see a list of the Roles assigned to them (i.e., Admin, Sales, etc.) What is the best way to do this??

Here is the Details part of my Controller:

// GET: Users/Details/5
public ActionResult Details(int? id)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    User user = db.Users.Find(id);
    if (user == null)
    {
        return HttpNotFound();
    }
    return View(user);
}

I need to add an array of strings in TempData["scripts"], but first I need to see if the string already exist... If it exist don't add it... else add it to the array.

This is what I have so far... It add the strings to the array... but I need to check the Tempdata first so it doesn't take duplicates...

@{
        var scripts = (List<string>)TempData["scripts"];
        scripts.Add("../Scripts/test.js");
        scripts.Add("../Scripts/testv.js");
        scripts.Add("../Scripts/testh.js");
    }

I received the following error message:

Compiler Error Message: CS0746: Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

from the following line:

<a href="@Url.Action((string)ViewBag.RequeryAction, (string)ViewBag.Vertical, new {  filters.size ="medium"})

How can I pass the filter properties to the controller?


I have defined the following types:

class Filters {
     string Layout;
  `  bool onlyBlack
}

class Image {
    Filters filter;
    double height;
}

I need to split the appSettings section into web.config and an external config file. The settings under web.config must remain unencrypted, whereas the settings in the configuration file must be encrypted.

Is this possible to accomplish at all? I get the configuration error "Unrecognized attribute 'configProtectionProvider'.

<!-- web.config -->
<appSettings file="AppSettings.config">
  <add key="URL" value="stackoverflow.com" />
</appSettings>

<!-- external config file -->
<appSettings configProtectionProvider="RsaProtectedConfigurationProvider">
  <EncryptedData>...</EncryptedData>
</appSettings>

I am using this command to encrypt the required settings. I then move the encrypted data to the external configuration file:

aspnet_regiis.exe -pef "appSettings" "."

I have developed a website in visual studio express for web 2013. The website pulls data from a SQLite database. This works fine in visual studio. Now I am trying to publish the website on a windows server 2008. I have setup IIS to launch the web site. However, when I launch the website from IIS, I get a Disk I/O error? The connnectionstring="datasource=C:....db;version=3;". Any ideas? Thanks for any help.

I'm using Dlls (Cells & PDF) from Aspose and ran into permission issue because the site must be set to Medium Trust while the DLLs requires Full Trust. I have attempted to different method to grant full trust to the DLLs while the site remains in Medium Trust. So far, I've tried the following: Created a separate custom medium trust config file with the code group for

<CodeGroup
   class="UnionCodeGroup"
       version="1"
       PermissionSetName="FullTrust"
       Name="Aspose.PDF_Asp.Net"
       Description="This code group grant full trust to Aspose.PDF">
       <IMembershipCondition
            class="StrongNameMembershipCondition"
            version="1"        
PublicKeyBlob="00240......."/>
</CodeGroup>

I've also tried adding to the web.config under the .Net Framework Config folder under the

<fullTrustAssemblies>
<add
   assemblyName="Aspose.Pdf"
   version="10.6.0.0"
   publicKey="00240000......"
/>

So far, none of these methods worked. So I'm wondering if it's possible to grant full trust to a specific page within the site without using a webservice. If I have a page that I can pass arguments and use that to run under Full Trust then I can mitigate at least this issue of Aspose not working under Medium Trust.

Thanks in advance.