I will create four projects each other works together.

  • desktop program ( as User Interface for entering datas )
  • web site ( for reporting )
  • web service ( for connecting database - from desktop program and reporting portal )
  • windows service ( for sending datas which are entered by users via desktop program to database )

Should i create one Visual Studio Solution which contains these four projects, or should i create different solutions for each of them?

What are the advantages of creating just one solution ?

Thank you.

in my local iis it is working fine but when i am hosting it on plesk it shows following error

401 (Unauthorized)

i'm using ksoap2 for call WCF web service and my service receive an base64 image string when i send small image its work correctly but when i send large image the service get me Soapfult object and this message : "The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader."

i searched for resolve that error and find that configuration in wcf web config

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService137" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http//:...MyServiceUrl..." binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IService137" contract="IService137"
          name="BasicHttpBinding_IService137" />
    </client>
  </system.serviceModel>

but its not work

This tutorial shows the implementation of Razor Pages in Asp.Net Core 2. However, when I run my CLI command:

 dotnet aspnet-codegenerator razorpage -m PatReg -dc ArtCoreDbContext
 -udl -outDir Pages\--referenceScriptLibraries

The output looks like below

enter image description here

I have the following ref-packages in my project.cs,

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.1.0-preview4-final" />
    <PackageReference Include="Microsoft.Composition" Version="1.0.31" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0-preview2-final" />
    <PackageReference Include="NETStandard.Library" Version="2.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
    <PackageReference Include="Sendgrid" Version="9.8.0" />
    <PackageReference Include="ASPSMS" Version="0.0.2" />
    <PackageReference Include="System.Composition" Version="1.1.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0-preview2-final" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
  </ItemGroup>

Am I missing a reference?

I'm working on an e-commerce website. What I'm trying to do right now is when users click on the "Open Modal" link, a modal dialog will open and show the product detail.

At the first time when I click on the ActionLink, it will call the QuickView action method in the Product controller and show the detail information of the product. However, when I click on the ActionLink for another product, it won’t call the QuickView action method. Also, the content of the modal dialog still displays the information of the previous product. Basically, the problem is that the action method only gets called in the first time that I click on the ActionLink. The action method won’t get called anymore when I click on the ActionLink again. When I right-click the page and inspect the element, I can see that the modal action link is generated correctly. I’m so confused about it. Please help.

The main view:

<div id="product">
    @foreach (var product in Model.Products)
    {
        @Html.Partial("ProductSummary", product)
    }
</div>

// The normal bootstrap modal with out any content in the modal-content div. Note that the id matches the data_target from the link
<div id="modal-container" class="modal fade product_view" tabindex="-1" 
   role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">

        </div>
    </div>
</div>

@section scripts {
    // The normal bootstrap behavior is to only grab the content for the 
    // modal once, if you need to pull in different partial views then the data on 
    // the modal will have to be cleared.
<script type="text/javascript">
    $(function () {
        $('#modal-container').on('hidden.bs.modal', function () {
            $(this).removeData('bs.modal');
            $('#modal-container .modal-content').empty();
        });
    });

    // callback from form modal
    function success() {
        alert("Success!");
    }
</script>

The product summary:

    <div class="caption">
        <h4 class="pull-right">@Model.Price.ToString("c")</h4>
        <h4>
            @Ajax.ActionLink(Model.Name, "ProductDetail", new { productId = Model.ProductID, returnUrl = Request.Url.PathAndQuery }, 
                new AjaxOptions { UpdateTargetId = "content", InsertionMode = InsertionMode.Replace })
        </h4>
    </div>
    <div class="space-ten"></div>
    <div class="btn-ground text-center">
        <button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("AddToCart", "Cart", new { ProductId = Model.ProductID})'">
            <i class="fa fa-shopping-cart"></i> Add To Cart
        </button>

        <div>
            // Create a link that calls the controller method that returns the partial view
            @Html.ActionLink("Open Modal", "QuickView", "Product", new { ProductId = Model.ProductID }, new
            {
                // Needed to link to the html of the modal
                data_target = "#modal-container",
                // Tells the bootstrap javascript to do its thing
                data_toggle = "modal"
            })
        </div>
    </div>
    <div class="space-ten"></div>
</div>

The quick view:

<div class="modal-header">
    <a href="#" data-dismiss="modal" class="class pull-right"><span 
class="glyphicon glyphicon-remove"></span></a>
    <h3 class="modal-title">@Model.Name</h3>
</div>
<div class="modal-body">
    <div class="row">
        <div class="col-md-6 product_img">
            <img 
src="http://img.bbystatic.com/BestBuy_US/images/products/5613/5613060_sd.jpg" 
class="img-responsive">
    </div>
    <div class="col-md-6 product_content">
        <h3 class="cost"><span class="glyphicon glyphicon-usd"></span> @Model.Price </h3>
        <div class="space-ten"></div>
        <div class="btn-ground">
            <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-shopping-cart"></span> Add To Cart</button>
            <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-heart"></span> Add To Wishlist</button>
        </div>
    </div>
</div>

image of the inspect element

I am able to view homepage but after creating Account Controller and View for Register, I am unable to view Register page using http://localhost:8080/Account/Register

I have a small project in VS2015 asp.net - c#, to read excel file data's. When I run it as localhost it's working fine. But after hosting to FTP, it's not working, giving error like

The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.
 
My Connection String - XLSX file
 
//String MyExcelFile = Server.MapPath(MyInput1.PostedFile.FileName); // Not Working
//String MyExcelFile = System.IO.Path.GetFullPath(Server.MapPath(MyInput1.PostedFile.FileName)); // Not Working
 
String MyExcelFile = MyInput1.PostedFile.FileName; // Working good in localhost
But giving error after published to ftp...........??????
 
String StrConn2 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + MyExcelFile + "; Extended Properties=\"Excel 12.0; HDR=YES; \"";
 
String MyExcelSheet = "[Sheet1$]";
String  MySQLSelect = "select * from " + MyExcelSheet;

Thanks for the helps!

I am trying to make a UI Web Application that Adds to and Updates entries in different database tables. Right now I am working on how to update previous entries. The object I am trying to update right now is Servers. The primary key of the object is ServerID. I am trying to have the View have a dropdownlist with all of the existing ServerIDs.

My Controller: UpdateServerController

In my HttpGet controller I put all of the current serverIds in a Viewbag so the user can select which server to alter in the view. Here is where the issue is. As you can see I am trying to pass both my object tblRTS_Server and an integer which is suppose to be the ServerID of the server that the user would like to change. How can I pass both the model object and the integer ServerID back to the HttpPost controller?

My View:

@model ApplicationInventory.tblRTS_Servers

@using (Html.BeginForm("UpdateServer"))
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
    <h4>tblRTS_Servers</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    @Html.HiddenFor(model => model.ServerID)

    <div class="form-group">
        <label style="padding-left:50px">Update Server Where ServerID: </label>
        <div class="col-md-offset-2 col-md-8">
            @Html.DropDownList("ServerId", null, htmlAttributes: new { @class = "form-control", @name = "ServerId"})
            @Html.ValidationMessageFor(model => model.ServerID, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ServerName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-offset-2 col-md-8">
            @Html.EditorFor(model => model.ServerName, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ServerName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.ServerType, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-offset-2 col-md-8">
            @Html.EditorFor(model => model.ServerType, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.ServerType, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Environment, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-offset-2 col-md-8">
            @Html.EditorFor(model => model.Environment, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Environment, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.Listener, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-offset-2 col-md-8">
            @Html.EditorFor(model => model.Listener, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Listener, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-9 col-md-3">
            <input type="submit" value="Save" class="btn btn-primary" />
        </div>
    </div>
</div>
}

I need to cancel a list of tasks that are running SQL queries after the wait time expires. I can implement CancellationToken to cancel the tasks. But the Cancellation is cooperative, so it means I have to check the cancel token status inside my action before every step. But in my case the sql queries are the ones that take long time, and I can only check the cancel token status before or after the query execution. In the later case it is useless, so how do I cancel the query execution inside these tasks based on the cancel token status?

public void EnqueueTask(Action action, CancellationToken cancelToken = default(CancellationToken))
{
    var task = new Task(action, cancelToken, TaskCreationOptions.LongRunning);
    if (_workTaskQueue.TryAdd(task))
    {
        TaskHandler?.Invoke
            (new TaskProcessingArguments
            {
                ISTaskAdded = true,
                Message = "Task Added to Queue",
                PendingTaskCount = _workTaskQueue.Count,
            });
    }
    else
    {
        TaskHandler?.Invoke
            (new TaskProcessingArguments
            {
                ISTaskAdded = false,
                Message = "Timedout while adding Task to Queue",
                PendingTaskCount = _workTaskQueue.Count,
            });
    }
}

public void DequeueTask(int maxConcurrency, CancellationToken ct)
{
    var tasks = new List<Task>();
    using (SemaphoreSlim concurrencySemaphore = new SemaphoreSlim(maxConcurrency))
    {
        foreach (var task in _workTaskQueue.GetConsumingEnumerable())
        {
            try
            {
                if (!(task.IsCanceled) && task.Status == TaskStatus.Created)
                {
                    tasks.Add(task);
                    task.Start();
                }
            }
            finally {
                concurrencySemaphore.Release();
            }
        }
    }
    Task.WaitAll(tasks.ToArray());
}

    void StartWorker()
    {
        Task.Factory.StartNew(() =>
        {
            try
            {
                taskQueue.DequeueTask(maxConcurrency, cancellationToken);
            }
            finally {
                lock (syncObj)
                {
                    IsCompleted = true;
                }
                //Logger.Info("Closing Worker task!!!");
            }
        }, TaskCreationOptions.LongRunning);
    }

I I'm trying to upload the image from android to SQL server consuming a web service but I don't know how searching in google I see this.

This is the Android studio.

public byte[] ReadFileFullname(string rootCompleted)
{
//get file
StreamReader reader = new StreamReader(@"" + rootCompleted);

BinaryReader binReader = new BinaryReader(reader.BaseStream);

//read file
byte[] binFile = binReader.ReadBytes(Convert.ToInt32(binReader.
BaseStream.Length));

//close reader
binReader.Close();
reader.Close();

return binFile;

}

and this one is in asp.net

[WebMethod]
public string SaveFile(string ruta, string filename, byte[] info)
{
     BinaryWriter writer = new BinaryWriter(File.Open((@"" + route+ filename),
     FileMode.OpenOrCreate,
     FileAccess.ReadWrite));

     writer.Write(info);

     writer.Close();

    return 0.ToString();

   }

I don't understand very well, what means route? Does this help me to upload the image to SQL server?

We are building a small traffic website in ASP.NET MVC and C#. For full text search, we are using Elasticsearch on our development machines currently. When I searched how to deploy it, most of the tutorials are spinning up an Azure Virtual Machine and deploying ES in it. Is there an alternative to that? We want to avoid the cost of renting an Azure VM. We are planning to use the Standard Service Plan to host our application.

Any help will be greatly appreciated.

I need to get ASP.NET_SessionId value in curl of a ASP.NET page; with the Console of Chrome the value is showed into

Cookie:displayCookieConsent=y; ASP.NET_SessionId=tqlqz5wek32qwut2deeyknti; _ga=zzzzzz; _gid=xxxxxxxxxxx

but if i set curl_setopt($ch, CURLOPT_HEADER, 1) the cookie don't appears in the header; also with a print_r($_COOKIE) only _ga and _gid are showed;

my php page is not , obvious, on the same server of asp.net page, but why if the cookie is showed into console don't appears in $_COOKIE? i need the ASP.NET_SessionId for create a second curl call Thank you

I am building a dashboard screen which requires multiple sql statements to return data. However all of these database calls are adding up in regards to performance.

As it stands now the code calls are online meaning I'm am making database calls inside my code. I would like to move all of the database calls to a stored procedure but I am not sure how to combine all of the database calls into one stored procedure to return multiple values as I have to display each of the values individually.

Can someone show me how to combine these select statements into one and return multiple values yo be used inside my code.

/*Pending Count */
Select Count(*)
FROM Issue
WHERE Issue.WorkerKeyFk =  lngWorkerKey
      And Issue.ClosedDate is Null

/* Get Today's Issue Count */             
Select Count(*)
FROM Issue
WHERE Issue.WorkerKeyFk =  lngWorkerKey
      And Issue.IssueDate =  FormatDateTime(dateTimes, DateFormat.ShortDate)

/* Over Due Issue Count */
Select Count(*) 
FROM Issue
WHERE Issue.WorkerKeyFk =  lngWorkerKey
      And Issue.DueDate <  FormatDateTime(dateTimes, DateFormat.ShortDate)
      And Issue.ClosedDate is null       

/*Get Closed Issue Count */
Select Count(*)
FROM Issue
WHERE Issue.WorkerKeyFk = lngWorkerKey
      And Issue.ClosedDate is not null 

I am using Kendo UI to add a calendar to my View in ASP.NET MVC. This is the section of code for that part

<div style="text-align: center; margin-top: 1em; margin-bottom: 1em;">
    <label class="inputLabel" for="client_name" style="display: inline-block;">Desired Due Date :</label>
        @(Html.Kendo().Calendar()
        .Name("desiredduedate")
        //.HtmlAttributes(new { style = "display: inline-block; border: 1px solid #BCBDBC" })
        .Footer(false)
        )
</div>

By default (with the code above) it looks like this:

enter image description here

Is there a way to remove the extra row on the bottom? I want only 5 rows instead of 6. I searched throughout the documentation for it but could not find anything.

I am creating dynamically an array, adding a line for each entry of some data. Each entry must have a button to do some stuff with it, but I am stuck at this point. I have this code to create the ASP.NET button:

<asp:Button ID="buttonyes" class="buttonyes" CommandArgument='<%= request.ID %>' 
            CommandName="AcceptRequest" OnClick='<%= ButtonPressed %>' runat="server"/>

But when I run it, I have multiple errors saying that:

The %= and < or > expressions are not valid.

When I click on the button, I want to call a function written in the index.aspx.cs file linked with my index.aspx, here is ButtonPressed function and with a filter in this function, it choose what action it should do:

protected void ButtonPressed(Object sender, CommandEventArgs e)
{
    Button btn = (Button)sender;
    switch (btn.CommandName)
    {
        case "AcceptRequest":
            AcceptRequest(btn.CommandArgument.ToString());
            break;
        case "RefuseRequest":
            RefuseRequest(btn.CommandArgument.ToString());
            break;
    }
}

The problem is that I don't succeed in passing those C# variables as a CommandArgument and CommandName.

I already tried those syntaxes, following some previous questions:

  • CommandArgument="<%: request.ID %>"
  • CommandArgument='<%: request.ID %>'
  • CommandArgument="<%= request.ID %>"
  • CommandArgument='<%= request.ID %>'

But none of them worked.

EDIT 1:

As @grek40 said below, the OnClick value should be replace like the following:

<asp:Button ID="buttonyes" class="buttonyes" CommandArgument='<%= request.ID %>' 
            CommandName="AcceptRequest" OnCommand="ButtonPressed" runat="server"/>

EDIT 2:

I would like to know how to pass a C# local variable since those button should be added in a foreach loop like so:

foreach (Request request in requests)
     {
     %>
         <tr>
              <td><%: request.applicant.Name + " (" + request.applicant.ID + ")" %></td>
              <td><%: request.software.Name %></td>
              <td><%: request.date %></td>
              <td class="actions">
                   <asp:Button ID="buttonyes" class="buttonyes" CommandName="AcceptRequest" CommandArgument="<# request.Id %>"  OnCommand="ButtonPressed" runat="server"/>
                   <asp:Button ID="buttonno" class="buttonno" CommandName="RefuseRequest" CommandArgument="<# request.Id %>" OnCommand="ButtonPressed" runat="server"/>
              </td>
          </tr>
      <%
      }

By the way, the code above doesn't work, since, as @Nino said, this only works for global variables.

How can I write an integration/unit test to pass the CSRF attacks in order to write a passing test for my CRUD operations?

How should I send a CSRF token to the controller that use the [ValidateAntiForgeryToken] attribute in my unit test project?

Note: I use NUnit framework as my Test Framework.

Edit:

I don't want to test the [ValidateAntiForgeryToken] attribute and I know that it isn't best practices. but in order to pass my unit tests where I've written this attribute (CRUD), I should provide it. otherwise, it won't pass my unit tests.

So i have a table with data that shows users and the assets they own. Each row is a different asset, so there is multiple rows for one user. Here's a sample row:

Sample Row

My question is what statement would I have to write to copy multiple rows of data from user 'AARONM' to user 'KODYM'? I believe I am over thinking it with the querys that I have tried, but I thought I would ask for outside help. Thank you in advance for your replies.

I am working on a website, where the client has asked to enable option for user to signup/login using google and Facebook accounts, so my question is how can i extract the email from google profile for storing in database. Here is my code:

 try
    {
        WebClient client = new WebClient();
        var urlProfile = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + access_token;


        string outputData = client.DownloadString(urlProfile);


        GoogleUserOutputData serStatus = JsonConvert.DeserializeObject<GoogleUserOutputData>(outputData);

        if (serStatus != null)
        {
            return serStatus;
            // You will get the user information here.
        }
    }
    catch (Exception ex)
    {
        //catching the exception
    }
    return null;
}

The problem is i am not getting user profile completely, receiving just user name.

I need to reproduce an old web site made in WebForm to ASP.Net MVC.

For now everything were going smoothly but in the last few pages, I've been required to add few DLL that were used by the old project.

I know that my ASP.Net app is signed with a strong name because I have my .snk and in the properties of the project, I see the snk selected in "Signing" dropdown.

The dll are inside my project in Libs/xxxxxx.dll and I added the reference in my project.

But when I try to use them, I get this error

Impossible de charger le fichier ou l'assembly 'XXXXXXX' ou une de ses dépendances. Un assembly avec un nom fort est requis. (Exception de HRESULT : 0x80131044)

My traduction to english:

Impossible to load the file or assembly "XXXXXXX" or one of his dependancies. An assembly with a strong name is required. (Exception HRESULT : 0x80131044)

I'm new to this "strong name assembly" things so i'm not sure what is required to make it use the DLL!

Anyone can help me with this problem!

I have created a ASP.net application,where i change the language base on its query string. I have two servers both are https ,but one is redirected by netscaler

https://testMyLiveCode.com
https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/?

For eg

https://testMyLiveCode.com/?ln=en

This is my asp.net code

string strNewLanguage = Request.QueryString["ln"].ToLower();
SessionHelper.Language = strNewLanguage ;
string strNewURL = Request.RawUrl.ToLower().Replace("ln=" + Request.QueryString["ln"], "");
 Response.Redirect(strNewURL);

What i actually do is that change the language depending on querystring and change the querystring and redirects

THis works perfectly with my https Server

https://testMyLiveCode.com/?ln=en

But this doesnt work with my netscaler url

https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/? 

This is my url

And after i added the querystring to it,it does not work https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/??ln=en

Can anyone help why this is not working as the url already has a ? in it??? Thanks for any help