I have a scenario, i am trying to withdraw an amount from account table using stored procedures and entity framework. here is my code:-

procedure:

alter proc [dbo].[RBS_spWithdrawAmount1] 
@AccountId bigint ,
@withdrawAmount int

as
begin

IF((select BalanceAmount from RBS_tblAccount where AccountId = @AccountId) > @withdrawAmount)
begin
update RBS_tblAccount set BalanceAmount = BalanceAmount - @withdrawAmount where AccountId = @AccountId 
end
else
begin
select 0
end
end

Controller POST:

[HttpPost]
    public ActionResult WithdrawAmount(RBS_tblAccount obj)
    {

        if(ModelState.IsValid)
        {

             var result =  db.RBS_spWithdrawAmount1(obj.AccountId, obj.WithDrawAmount);

            if(Convert.ToInt32(result) == -1)
            {
                TempData["Errormsg"] = "InSufficient Balance";
            }
            else
            {
                return RedirectToAction("ViewAccounts");
            }
        }
        return View();
    }

i am getting "The data reader returned by the store data provider does not have enough columns for the query requested." error in auto generated file on this line :-

 return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<int>>("RBS_spWithdrawAmount1", accountIdParameter, withdrawAmountParameter);

please help with this..

How to do bundling and minification on multiple cdn files with mvc c#? I have tried with "Using CDN in ASP.NET MVC bundles" but didn't get the solution.

I am writing the web application which allows you to optimize SQL query.

I have such a view:

<div id="codeeditor" style="margin-right:20px; float:left"  >
    <script>
        var editor = CodeMirror(document.getElementById("codeeditor"), {
        mode: "sql",
        theme: "dracula",
        tabSize: 5,
        lineNumbers: true,
        });
        editor.setSize(500, 500);
    </script>
    <input type="submit" value="start" id="btnClick" />
</div>

<div id="codeeditor1">
    <script>
        var editor1 = CodeMirror(document.getElementById("codeeditor1"), {
            mode: "sql",
            theme: "dracula",
            tabSize: 5,
            lineNumbers: true,

        });
        editor1.setSize("45%", 500);
   </script>

</div>


@section scripts{
<script type="text/javascript">
    $(document).ready(function () {
       $("#btnClick").click(function () {
            var f = {};
            f.url = '@Url.Action("Demo", "Home")';
            f.type = "POST";
            f.dataType = "json";
            f.data = JSON.stringify({ sourceSqlCode: editor.getValue() });
            f.contentType = "application/json";
            editor1.setValue(@ViewBag.readyQuery);
            f.success = function (response) {
                alert("success");
            };
            f.error = function (response) {
                alert("err");
            };
            $.ajax(f);
        });
    });
</script>
}

Here is my controller which handles button clicking

[HttpPost]
    public ActionResult Demo(string sourceSqlCodee)
    {
        //here I use my libraries and optimize query

        ViewBag.readyQuery= optimizedQuery;

        return View();
    }

All I need Is to pass query to controller by clicking the button and pass it back to the view after modifying into the codeeditor1

It simply doesn't work because scripts are being run earlier than my controller method. How can I do that? Thanks!

In Visual Studio 2017, if you create a new ASP.NET Core Web Application (Razor Pages) configured to use Individual user accounts and Store user accounts in- app, the "Forgot password" flow is as follows.

  1. User goes to login page
  2. User click "Forgot your password?"
  3. User enter email address and click "Submit"
  4. An email is sent to the user with a link to reset password. This link contains the user id (Guid), and a code used for reset.
  5. User click link and is taken to the "Reset password" page.
  6. User enter Email, Password and Confirm password and click Reset.

Password is then reset.

My question is if there is some specific reason the user is requested to enter his email in step 6, considering that the user id is already in the URL. The reset password page could look up the user by the id and not ask for the email address.

I assume it's a security-feature, in case someone intercepts the link. But intercepting the link would likely mean intercepting the email containing the link, and then the users email would be known anyway. So I feel like I am missing something.

I have below settings in webconfig

 <sectionGroup name="enyim.com">
      <!-- Memcached -->
      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection,Enyim.Caching" />
    </sectionGroup>

<enyim.com>
    <memcached protocol="Binary">
      <servers>
        <add address="endpoint" port="15651"></add>
      </servers>
    </memcached>
  </enyim.com>

Below code

var mc = new MemcachedClient();
                var stat = mc.Store(StoreMode.Set, "Hello", "World");

Always false

MemcachedClientConfiguration config = new MemcachedClientConfiguration();
                config.AddServer("endpoint", 134311);
                config.Protocol = MemcachedProtocol.Binary;
                var mc = new MemcachedClient(config);
                var stat = mc.Store(StoreMode.Set, "Hello", "World");

Always false

After local setup I am gettind gerror

Always false

What I am missing

how to solve Format Issue in text editor for ms word file . i have use Tinymce Editior. is this possible to solve this issue.

I am attempting to convert the date fetched from a datepicker to a different format . The date format on my system is : "25/04/2018" which I want to convert to "2018-04-25". I tried :

 string tbdate = textboxdate.Text;
            DateTime lastdate = DateTime.ParseExact(tbdate,
                       "dd/mm/yyyy",
                       System.Globalization.CultureInfo.InvariantCulture);

            string newFormat = lastdate.ToString("yyyy-MM-dd");

But the value I get in lastdate is "25/01/2018 12:04:00 AM". Why is showing a different date.I need it to be the current date.

i'm working in eshop order basket project. i want help for solving rabbitmq error from this code:

using Microsoft.Extensions.Logging; 

using Polly; 

using Polly.Retry; 

using RabbitMQ.Client; 

using RabbitMQ.Client.Events; 

using RabbitMQ.Client.Exceptions; 

using System; 

using System.IO; 

using System.Net.Sockets; 



namespace InfiniteWorx.MRU.BuildingBlocks.EventBusRabbitMQ 

{ 

    public class DefaultRabbitMQPersistentConnection 

       : IRabbitMQPersistentConnection 

    { 

        private readonly IConnectionFactory _connectionFactory;  

        private readonly ILogger<DefaultRabbitMQPersistentConnection> _logger; 

        private readonly int _retryCount; 

        IConnection _connection; 

        bool _disposed; 



        object sync_root = new object(); 



        public DefaultRabbitMQPersistentConnection(IConnectionFactory 
connectionFactory, ILogger<DefaultRabbitMQPersistentConnection> logger, int 
retryCount = 5) 

        { 

            _connectionFactory = connectionFactory ?? throw new 
ArgumentNullException(nameof(connectionFactory)); 

            _logger = logger ?? throw new 
ArgumentNullException(nameof(logger)); 

            _retryCount = retryCount; 

        } 



        public bool IsConnected 

        { 

            get 

            { 

                return _connection != null && _connection.IsOpen && 
!_disposed; 

            } 

        } 



        public IModel CreateModel() 

        { 

            if (!IsConnected) 

            { 

                throw new InvalidOperationException("No RabbitMQ connections 
are available to perform this action"); 

            } 



            return _connection.CreateModel(); 

        } 



        public void Dispose() 

        { 

            if (_disposed) return; 



            _disposed = true; 



            try 

            { 

                _connection.Dispose(); 

            } 

            catch (IOException ex) 

            { 

                _logger.LogCritical(ex.ToString()); 

            } 

        } 



        public bool TryConnect() 

        { 

            _logger.LogInformation("RabbitMQ Client is trying to connect"); 



            lock (sync_root) 

            { 

                var policy = RetryPolicy.Handle<SocketException>() 

                    .Or<BrokerUnreachableException>() 

                    .WaitAndRetry(_retryCount, retryAttempt => 
TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) => 

                    { 

                        _logger.LogWarning(ex.ToString()); 

                    } 

                ); 



                policy.Execute(() => 

                { 

                    _connection = _connectionFactory 

                          .CreateConnection(); 

                }); 



                if (IsConnected) 

                { 

                    _connection.ConnectionShutdown += OnConnectionShutdown; 

                    _connection.CallbackException += OnCallbackException; 

                    _connection.ConnectionBlocked += OnConnectionBlocked; 



                    _logger.LogInformation($"RabbitMQ persistent connection 
acquired a connection {_connection.Endpoint.HostName} and is subscribed to 
failure events"); 



                    return true; 

                } 

                else 

                { 

                    _logger.LogCritical("FATAL ERROR: RabbitMQ connections 
could not be created and opened"); 



                    return false; 

                } 

            } 

        } 



        private void OnConnectionBlocked(object sender, 
ConnectionBlockedEventArgs e) 

        { 

            if (_disposed) return; 



            _logger.LogWarning("A RabbitMQ connection is shutdown. Trying to 
re-connect..."); 



            TryConnect(); 

        } 



        void OnCallbackException(object sender, CallbackExceptionEventArgs e) 

        { 

            if (_disposed) return; 



            _logger.LogWarning("A RabbitMQ connection throw exception. 
Trying to re-connect..."); 



            TryConnect(); 

        } 



        void OnConnectionShutdown(object sender, ShutdownEventArgs reason) 

        { 

            if (_disposed) return; 



            _logger.LogWarning("A RabbitMQ connection is on shutdown. Trying to re-connect..."); 



            TryConnect(); 

        } 

    } 

} 

This is eroor msg when running the code:

RabbitMQ.Client.Exceptions.BrokerUnreachableException: 'None of the specified endpoints were reachable'

ArgumentNullException: Value cannot be null. ConnectFailureException: Connection failed

I have 5 years of experience using C# asp.net using web forms and still working on the same technology but nowadays there are many technologies came in the market, i want to know whether asp.net web-forms no more using in the companies.

I have a problem that i think is easy to solve however im stuck.

I created a HeaderTemplate in my gridview with a DDL control and that messed up my RowCommand event.

I'm not able to get the value of the cell when i press the select linkbutton anymore (This worked before i created a HeaderTemplate / TemplateField)

enter image description here

ASPX MArkup

   <asp:TemplateField HeaderText="Status">
        <EditItemTemplate>
            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
        </EditItemTemplate>
        <HeaderTemplate>
            <asp:DropDownList ID="ddlStatusHeader" AutoPostBack="true" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlStatusHeader_SelectedIndexChanged" runat="server">
                <asp:ListItem>Status</asp:ListItem>
            </asp:DropDownList>
        </HeaderTemplate>
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
        </ItemTemplate>
        <HeaderStyle Font-Bold="False" Font-Size="14px" />
        <ItemStyle Font-Size="12px" HorizontalAlign="Left" Width="6%" />
    </asp:TemplateField>

RowCommand:

protected void gwActivity_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    GridViewRow row = ((e.CommandSource as Control).NamingContainer as GridViewRow);


            txtStatus.Text = row.Cells[1].Text;
}

Can it be that i need to get the TextBox1 OR Label1 "control" of the selected row? Because i think it looks at DropDownList control at the moment?

Can anyone see what the problem is?

I've got a ModalPopupExtender containing a RadioButtonList which has 2 ListItem buttons.

When the popup is visible, one button is already correctly selected.

If I click the other button, I get Page_Load followed by OnSelectedIndexChanged events as expected.

My Page_Load handler calls ModalPopupExtenderExchangeDevice.Show() which causes the popup to still be visible when the code-behind completes.

The opposite button is now selected, as expected. If I now click the un-selected button, again Page_Load followed by OnSelectedIndexChanged events fire, but this time the ModalPopupExtender is NOT visible.

Any ideas why it isn't?

Thanks

Is the amount of RAM used in .net-Core projects more than other projects

In my application I've been using the client's IP address to allow him to login into some specific page. I'll be saving the client side IP in DB and match the request IP with it and do the validation.

However, my application is up and running in production. Earlier my client was on the same network in which my organization was, so the IP wasn't public. While providing the same service to other client he wasn't in our organization network, so he has a public IP.

How to handle this now? Any alternative to handle this situation without changing the application logic and changing something at the network Side.

So I've been scouring the internet for a decent solution to this, but nothing I've tried has worked. Question is, I have DropDownLists (4 of them) that all look something like this: (These are all in the View)

Html.DropDownList("SeriesColor", new List<SelectListItem>

{

new SelectListItem {Text = "GR- Green", Value = "GR"},

new SelectListItem {Text = "BL - Blue", Value = "BL"},

new SelectListItem {Text = "LB - Light Blue", Value = "LB"},

new SelectListItem {Text = "NO - None", Value = "NO"},

new SelectListItem {Text = "OR - Orange", Value = "OR"},

new SelectListItem {Text = "PP - Purple", Value = "PP"}

I also have a text box and button: (Also in the View)

 <input id="addD4" type="text" />

 <button class="btn btn-default" type="button">Add Default</button>

And what I want to do is allow the user to input a value (anything), press the button and have it added to the dropdownlist. Most of the solutions I've seen are either outdated, or are not supporting MVC/ Razor.

So I've been scouring the internet for a decent solution to this, but nothing I've tried has worked. Question is, I have DropDownLists (4 of them) that all look something like this: (These are all in the View)

Html.DropDownList("SeriesColor", new List<SelectListItem>

{

new SelectListItem {Text = "GR- Green", Value = "GR"},

new SelectListItem {Text = "BL - Blue", Value = "BL"},

new SelectListItem {Text = "LB - Light Blue", Value = "LB"},

new SelectListItem {Text = "NO - None", Value = "NO"},

new SelectListItem {Text = "OR - Orange", Value = "OR"},

new SelectListItem {Text = "PP - Purple", Value = "PP"}

I also have a text box and button: (Also in the View)

 <input id="addD4" type="text" />

 <button class="btn btn-default" type="button">Add Default</button>

And what I want to do is allow the user to input a value (anything), press the button and have it added to the dropdownlist. Most of the solutions I've seen are either outdated, or are not supporting MVC/ Razor.

I have an ASP.NET website that uses an ajax tab container for the whole body. the ux is pretty bad on mobile and I was wondering what the best way to go about fixing this would be. I know i can use media queries to redirect to different html pages for mobile, but wondering if there is a good way to style a tab container for mobile use or if i need to get rid of the tab container all together

Also is there is a good emulator for testing newer phones (i currently am using opera for a galaxy S3)

I have seen an example on how to dynamically add or remove input type text using j-query but my issue is that when I am doing it with a normal page with a form runat ="server" it is reading the j query function but when I am setting this function in the child page having the form runat = server inside the master page it is not reading the function this is my asp.net code:

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

<input id="btnAdd" type="button" value="Add" />
<br />
<br />
<div id="TextBoxContainer">
<!--Textboxes will be added here -->
</div>
<br />

    <button id="btnGet" runat="server" onserverclick="Submit_Click">Submit</button>
    <asp:HiddenField ID="hdnfldVariable" runat="server" />

    </asp:Content>

My j query function is :

       <script type="text/javascript"    src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
       <script type="text/javascript">
$(function () {
    $("#btnAdd").bind("click", function () {
        var div = $("<div />");
        div.html(GetDynamicTextBox(""));
        $("#TextBoxContainer").append(div);
    });
    $("#btnGet").bind("click", function () {
        var values = "";
        $("input[name=DynamicTextBox]").each(function () {
            values += $(this).val() + "\n";
        });
        alert(values);
        hdnfldVariable.value = values;
    });
    $("body").on("click", ".remove", function () {
        $(this).closest("div").remove();
    });
});
function GetDynamicTextBox(value) {
    return '<input name = "DynamicTextBox" type="text" value = "' + value + '" />&nbsp;' +
            '<input type="button" value="Remove" class="remove" />'
}

And my c# button click event :

    protected void Submit_Click(object sender, EventArgs e)
    {

    string variable = hdnfldVariable.Value;
    string y = variable.Replace("\r\n", " , ");
    string z = y.Substring(0, (y.Length - 2));

    }      

I have been tasked with making an asp.net webform SSO compliant using ADFS 3.0

The scenario: domain A hosts the asp.net webforms that is accessed from domain B across the internet(firewall rule etc in place, https on webforms). Domain B also has an instance of ADFS 3.0 and the AD

When a user connects to the webforms on domain A from Domain B, it needs to authenticate with the ADFS 3.0 server on domain A and then decide to either let him through or redirect to login screen.

I have the theoretical knowledge from reading how to configure ADFS server for the relying party etc. my problem is the code. How, in my webforms do I get his browser token and authenticate it on domain domain B(access a few of his claims like email and name)

I am a total newbie to ADFS question and I would appreciate some sample code and/or pointers or links.

Thank you guys and girls.

My asp.net web app requires downloading files from DropBox. In DropBox, I created an app and have the API key and Auth Token, Secret, etc. In my web app I have reference to Dropbox.Api and can create DropboxClient.

Like so:
Dim myDBClient As New DropboxClient("my_token_auth")

What do I do next? Does anyone have sample code. I read I need to call async method to download such as code below.

But the code is not working. Not failing either but does nothing.

Any help would be appreciated. Thank you

Dim folder As String = "C:\Data"
Dim file2 As String = "myFile.txt"

Using response = myDBClient.Files.DownloadAsync("/" & folder & "/" & file2)
 Using fileStream = File.Create("C:\Data\myFile.txt")
      (response.GetContentAsStreamAsync()).CopyTo(fileStream))
 End Using
End Using

JS code

          <script>
    handleClick = function(val) {
          document.getElementById('selectnumber').innerHTML = val;
      };
</script>

HTML code

 <ul><li><fieldset class="rating">
    <legend>Please rate:</legend>
    <input type="radio" id="star5" onclick="handleClick('star5')" name="rating" value="5" /><label for="star5" title="Rocks!">5 stars</label>
<input type="radio" id="star4"  onclick="handleClick('star4')" name="rating" value="4" /><label for="star4" title="Pretty good">4 stars</label>
<input type="radio" id="star3"  onclick="handleClick('star3')" name="rating" value="3" /><label for="star3" title="Meh">3 stars</label>
<input type="radio" id="star2"  onclick="handleClick('star2')"name="rating" value="2" /><label for="star2" title="Kinda bad">2 stars</label>
<input type="radio" id="star1"  onclick="handleClick('star1')" name="rating" value="1" /><label for="star1" title="Sucks big time">1 star</label>
</fieldset>
                <asp:Button ID="Rating_btn" runat="server" Text="Rate" OnClick="Rating_btn_Click"/>
<br /><asp:Label ID="selectnumber" runat="server" Text=""></asp:Label>

css code

.rating {float:left;}
.rating:not(:checked) > input {
    position:absolute;
    top:-9999px;
    clip:rect(0,0,0,0); }

.rating:not(:checked) > label {
    float:right;
    width:1em;
    padding:0 .1em;
    overflow:hidden;
    white-space:nowrap;
    cursor:pointer;
    font-size:200%;
    line-height:1.2;
    color:#ddd;
    text-shadow:1px 1px #bbb, 2px 2px #666, .1em .1em .2em rgba(0,0,0,.5); }

.rating:not(:checked) > label:before {content: '★ ';}

.rating > input:checked ~ label {
    color: #f70;
    text-shadow:1px 1px #c60, 2px 2px #940, .1em .1em .2em rgba(0,0,0,.5);}

.rating:not(:checked) > label:hover,
.rating:not(:checked) > label:hover ~ label {
    color: gold;
    text-shadow:1px 1px goldenrod, 2px 2px #B57340, .1em .1em .2em rgba(0,0,0,.5);}

.rating > label:active {
    position:relative;
    top:2px;
    left:2px; }

I'm trying to get the value of the star and display it on my screen. Unfortunately it is not doing it, please help me i have tried everything its urgent!!.. my class did to me a lot of problem so he may be the cause.