I am scraping data from a website using (Httprequest) c# after some times its demanding CAPTCHA are you a human. how to resolve this issue please suggest ASAP . about 1 , 2 hours its work fine but after after that its not working. demanding CAPTCHA when navigating url using (Httprequest) . what the issue how can i manage this problem because when i stop the system after 30 to 40 minutes again start my software its work fine.

please resolve issue

I am trying to access a session variable in aspx but I think there is an issue with my syntax somewhere.

Under page load:

Session["UserName"]= username.Substring(8).ToString();  // This is ok as far as I know. 

Issue is with the asp bit:

<asp:TextBox ID="ATextBox" runat="server" Text="<% Session["UserName"] %>" /> 
<asp:TextBox ID="ATextBox" runat="server" Text="<%# Session["UserName"] %>" /> 

I have also tried the above (one at a time) with .ToString() at the end too. But I keep getting errors:

Either The server tag is not well formed or the server tag contains % %

One thing that might make a difference is the Textbox is inside a GridView, (it is inside a ContentTemplate)but not a boundfield.

I have a Class Library which needs the .NET reference to work as it utilizes a lot of System APIs but I am unable to add the reference from the Add References dialogue box. The .NET reference isn't available under Assemblies in the Reference Manager.

This is how my project looks like and I get the following error when I build this project:

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

enter image description here

Following is the screenshot of my Reference Manager

enter image description here

I want the .NET reference as attached to the image below.Any idea how can I solve this issue? Thanks in advance :)

enter image description here

I have an ASP.NET Core project in which I connect to a different api using HttpClient. Everything works fine when I run it locally but I get an exception when I publish my code to a local folder and then run it in IIS.

Here is a codesample of where it goes wrong

using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Add("X-Access-Token", ClientToken);
    client.DefaultRequestHeaders.Add("X-Client-ID", ClientId);
    var response = await client.GetAsync(url);
    if (!response.IsSuccessStatusCode) throw new Exception(response.ReasonPhrase);
    var str = await response.Content.ReadAsStringAsync();
    return str;
}

Here is the error I can see in the log

Executing action method arnvanhoutte.Controllers.API.WunderlistController.GetUser (arnvanhoutte) with arguments ((null)) - ModelState is Valid
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The operation timed out
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
   at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at arnvanhoutte.Repositories.PolarRepository.<CreateRequestAsync>d__6.MoveNext() in C:\Users\av427g\Documents\Visual Studio 2017\Projects\arnvanhoutte\arnvanhoutte\Repositories\PolarRepository.cs:line 48

What causes this strange behavior and how can I fix it?

I am trying to throw a simple HttpException 404 error from code behind in a class in MVC asp.net core 2 web application.

In my one project, I configured http cookie "< httpcookies httponlycookies="true" requiressl="true" lockitem="true" / > " in web.config file. and i set user information in session when user logged. but when i redirect to another page at that time session is regenerate my user authentication is not work.

How can i solve?

I need a piece of advice. Here is my problem. I need to generate an image on the server based on some data (to be specific, date intervals) and paste it on an email also generated on the server. My web site is made on ASP.Net MVC, for generating emails I use RazorEngine. On the fron-end side for the similar task (displaying the same date intervals as a timeline) I use Google Timeline chart. Also Telerik Kendo is used. So, I need to get an image similar to Google Timeline chart, but on the server. I wonder whether tools for making this task simple exists.

I have tried to implement the below code but it is returning a null value.

[WebMethod]
public decimal ConvertGOOG(decimal amount, string fromCurrency, string toCurrency)
{
    WebClient web = new WebClient();
    string url = string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount);
    string response = web.DownloadString(url);
    Regex regex = new Regex("rhs: \\\"(\\d*.\\d*)");
    var val = regex.Match(response).Groups[1].Value;
    decimal rate = System.Convert.ToDecimal(regex.Match(response).Groups[1].Value);
    return rate;
}

From the code below I am getting val value as null. Here I am trying to convert 1 USD to INR.

I have also tried this code but getting 403 forbidden error.

var request = WebRequest.Create(apiURL);

//Get the Response
var streamReader = new StreamReader(request.GetResponse().GetResponseStream(), System.Text.Encoding.ASCII);

//Grab your converted value (ie 2.45 USD)
var result = Regex.Matches(streamReader.ReadToEnd(), "<span class=\"?bld\"?>([^<]+)</span>")[0].Groups[1].Value;

I had tried Google API for the conversion of code but it is still returning the null value.

How Can I Convert 1 USD to INR?

Please i have 2 gridviews. I have been able to pass row from the first gridview to the second gridview when checkbox in first gridview is selected. But now I want to remove the row that was added to the second gridview when checkbox in the first gridview is deselected. Here's my code

$(function () {
                // Calls when checkbox is checked.
                $('[id*=GridView1] [id*=GridView1_chkRow]').on('click', function () {
                    if ($(this).is(":checked")) {
                        //Second Gridview.
                        var gridview2 = $('[id*=gvSelected]');

                        //Get Row Which Checbox is Selected.
                        var tr = $(this).closest('tr');

                        //Ignoring the checkbox column so that it wont get added in second gridview.
                        var tds = $(tr).find('td').not('.IgnoreCheckBoxColumn');
                        var row = '<tr>';
                        for (var i = 0; i < tds.length; i++) {
                            row += tds[i].outerHTML;
                        }
                        row += '</tr>';

                        //Appending selected row to second gridview.
                        gridview2.append(row);
                    }

I am using Bootstrap tab panels in an ASP.NET page. I am setting the focus to the selected tab using jQuery. On page load event, I want to get the clicked tab and bind the content of that tab. How can I do that?

I am wanting to create a download link which will download a folder full of images based on the link directory, or create multiple links which will toggle a download of single images.

I have found the code below, however, this only seems to work on images which are local, not from a external url which is where I store my images, does anyone have any suggestions?

<a href="/path/to/image" download>
    <img src="/path/to/image" />
</a>

I use: SignalR 2.2.2 in SqlScaleoutConfiguration Rebus 3.0.1

Some events stored in Rebus are handled by a notification hub and pushed to the clients using signalR.

Everything works fine, but this morning, after having published a new version, none of the clients received the "new version" message probably because of the following exception:

10:39:04.586| |ERROR| |ProcessId=8196| |ThreadId=5| |SignalR.SqlMessageBus| |Stream 0 : Error starting SQL notification listener: System.Runtime.Serialization.SerializationException: Type 'Rebus.Transport.TransactionContext' in Assembly 'Rebus, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Server stack trace: 
   at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)
   at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage..ctor(IMethodCallMessage mcm)
   at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.SmuggleIfPossible(IMessage msg)
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System._AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.Data.SqlClient.SqlDependency.CreateProcessDispatcher(_AppDomain masterDomain)
   at System.Data.SqlClient.SqlDependency.ObtainProcessDispatcher()
   at System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults)
   at Microsoft.AspNet.SignalR.SqlServer.ObservableDbOperation.StartSqlDependencyListener()

The message in Rebus queue results as correctly handled.

The handler is this:

public async Task Handle(ApplicationVersionEvent message)
{
    await
        Clients.All.CheckApplicationVersion(new ApplicationCurrentVersionNotification
        {                    
            CurrentVersion = message.CurrentVersion
        });
}

It was resolved by a restart, but I need to understand what happened.

I similar issues are:

but I think this is not the same case.

I have a login page and when any user login the application then there is a column called flag in the database which becomes true and logs out the application then it becomes false.The problem is that if we log in the application then we directly close the browser then flag value has to be false but it is not

I am displaying a form which allows users to edit or create entries in a Beer table. To help with this, the form has a DropDownList for the breweries present in the Brewery table. When the drop down list selection is changed a list of beers for the newly-selected brewery is displayed alongside the rest of the form by some JavaScript. The drop-down list is created like this:-

@Html.DropDownListFor(m => m.SelectedBreweryID, 
                      Model.Breweries,
                      new { @onchange   = "BreweryChanged();", 
                            @class      = "pulldown" })

So far, so good. But when the page is initially displayed, a brewery is selected in the pulldown, but since it hasn't changed, the onchange event isn't fired and thus the BreweryChanged function isn't called.

Is there any way to get this JavaScript function invoked on the initial page display?

Referring to this list here I have tried adding:-

@onload = "BreweryChanged();"

and

@onpageshow = "BreweryChanged();"

but these appear to have no effect. (None of the other events look very promising.)

I'm searching for a way for downloading big files (like 2 - 4 Gb) on a bearer token protected api endpoint, that works on all common browsers (IE 11, Chrome, Firefox, Android Browsers, Safari). It should work with angular/ts and browsers only (without providing an app).

The problem with FileSaver

At the moment I'm using eligrey/filesaver which kinda combines all browser specific possibilities for a client side blob download. With this approach i can easely use the bearer token (ex. with http interceptors).

The problem is, IE pumps up the RAM and gets stuck at 1.4 GB download.

The problem with StreamSaver

I saw there is a new modern way with StreamSaver.js, which allows streaming directly on disk, but it is only available on chrome and opera.

The Problem with an unprotected endpoint

Another common way for such a scenario would be to allow anonymous access for the download endpoint, with requesting a one-time-token first, creating a url containing this token, let the user download it directly via browser with opening a new tab and immediately close it after starting the download.

This approach takes 2 requests for a download and looks flashy for a user to watch. I'm not sure, if this works on mobile browsers (opening new tab for download) and it looks like a hack, at least to me. The API have to ensure that url's are only valid during a short period of time and/or cannot be used 2 times in a row.

Ideas, anyone?

Does anyone knows a clean, modern/state of the art & performant way for such a common scenario?

How are the big companys dealing with this problem (google drive, dropbox, amazaon)?

I personally would prefer to let the browser download the file (instead of client side blob download). Maybe there is a way to "inject" the bearer tokens as default request headers to the browser when the client clicks a (href'ed) link.

Why isn't it easy for an modern angular rich-client to delegate a protected binary download to the browser?

There is a method for esclude aspx page from pipeline in the use nancy.Owin in a old webform site project not compiled?

When I configure nancy the post-back and the request is an aspx page the post-back is deleted because nancy delete it and recall the page.

public void NancyConfig(IAppBuilder app)
{
    app.UseNancy(options =>
    {
        options.Bootstrapper = new MyBootstrapper();
        options.PerformPassThrough = (context => context.Response.StatusCode == HttpStatusCode.NotFound);
    });

    app.UseStageMarker(PipelineStage.MapHandler);
}

The options.PerformPassThrough wipe the post-back content and call the page. For not post-back is ok but in post-back elaboration this present an infinite loop.

How to configure NancyFx for not wipe post-back in passtrought option?

Package.config below:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="bootstrap.less" version="3.3.5" targetFramework="net40" />
  <package id="Bootstrap.v3.Datetimepicker" version="4.17.45" targetFramework="net40" />
  <package id="CrystalDecisions.CrystalReports.Engine" version="1.0.0" targetFramework="net40" />
  <package id="CrystalDecisions.ReportAppServer" version="1.0.0" targetFramework="net40" />
  <package id="CrystalDecisions.ReportSource" version="1.0.0" targetFramework="net40" />
  <package id="CrystalDecisions.Shared" version="1.0.0" targetFramework="net40" />
  <package id="CrystalDecisions.Web" version="1.0.1" targetFramework="net40" />
  <package id="EntityFramework" version="5.0.0" targetFramework="net40" />
  <package id="jQuery" version="1.9.1" targetFramework="net40" />
  <package id="jQuery.UI.Combined" version="1.8.20.1" targetFramework="net40" />
  <package id="jQuery.Validation" version="1.9.0.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.Mvc" version="3.0.50813.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.Providers.Core" version="1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.Providers.LocalDB" version="1.1" targetFramework="net40" />
  <package id="Microsoft.AspNet.Razor" version="1.0.20105.408" targetFramework="net40" />
  <package id="Microsoft.AspNet.WebPages" version="1.0.20105.408" targetFramework="net40" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
  <package id="microsoft-web-helpers" version="1.0" targetFramework="net40" />
  <package id="Modernizr" version="2.5.3" targetFramework="net40" />
  <package id="Moment.js" version="2.9.0" targetFramework="net40" />
  <package id="MvcSiteMapProvider" version="3.1.0.0" targetFramework="net40" />
  <package id="MvcSiteMapProvider.MVC3" version="4.6.22" targetFramework="net40" />
  <package id="MvcSiteMapProvider.MVC3.Core" version="4.6.22" targetFramework="net40" />
  <package id="MvcSiteMapProvider.Web" version="4.6.1" targetFramework="net40" />
  <package id="WebActivatorEx" version="2.0.4" targetFramework="net40" />
</packages>

Web.Config

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Raven.Client.Lightweight" publicKeyToken="37f41c7f99471593" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Raven.Abstractions" publicKeyToken="37f41c7f99471593" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.1" newVersion="3.0.0.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

enter image description here Web.configError Image

See above picture. I have faced error as

An exception of type 'System.MissingMethodException' occurred in System.Web.Mvc.dll but was not handled in user code

I am trying to create a custom Property Editor in Umbraco.

Package.manifest

{
    propertyEditors: [
        {
            alias: "Notification Ribbon",
            name: "Notification Ribbon",
            editor: {
                view: "~/App_Plugins/NotificationRibbon/NotificationRibbon.html"
            }          
        }
    ],
    javascript: [
        '~/App_Plugins/NotificationRibbon/NotificationRibbon.controller.js'
    ]
}

and in my controller

angular.module("umbraco").controller("NotificationRibbon.Controller", function($scope) {
    $scope.opennotification = function() {

        if (!$scope.control) {
            $scope.control = {}
        }
        if (!$scope.model) {
            $scope.model = {}
        }


        $scope.overlay = {
            title: "Nottification ribbon",
            view: "/ultradata/Views/common/overlays/notificationribbon/notificationribbon.html",
            rteeditor: $scope.model.value.rteeditor,
            NotifyLinkClass: $scope.model.value.NotifyLinkClass,
            Location: $scope.model.value.Location,
            ButtonValue: $scope.model.value.editModel,
            show: true,
            submit: function(model) {
                $scope.overlay.show = false;
                $scope.overlay = null;
                $scope.model.value = {};
                $scope.model.value.rteeditor = model.rteeditor.value;
                $scope.model.value.NotifyLinkClass = model.NotifyLinkClass;
                $scope.model.value.Location = model.Location;
                $scope.model.value.ButtonValue = model.ButtonValue;

            },
            close: function(oldModel) {
                $scope.overlay.show = false;
                $scope.overlay = null;
            }
        }

    }

});

the Property editor value is being stored like this on the server:

{
        "id": 19151,
        "alias": "not",
        "value": {
            "rteeditor": "<p>fghfhfghfgh</p>"
        }
    }

When I tried to take the value and display the notification Text value in Razor code

<div class="gayaaa">@Umbraco.Field("not")</div>

the Result returning the Entire object in Screen

enter image description here

I`m using mvc razor pages and I have got this link element on my page:

<a target="@name" href="@url" onclick="createPopup(@name)">

My js looks like this:

function createPopup(name) {
    var popup = window.open('about:blank',  name  ,'width=800,height=' + getPopupHeight() + ',top=100,left=300');
    var input = '<input id="Popup" name="Popup" value="True" type="hidden"></form>';
    popup.append(input);
    popup.focus();
}

Input is appended correctly and I can access it until redirect to @url is processed. After that it`s replaced.

I need to recognize if it`s popup in layout.cshtml where I have something like:

@if (Request.Params["Popup"] == "True")
{

So, my question is, it is possible somehow? Idealy with similiar approach.

I have a web application, where I want to save images in my database. In my Application.Web I have a folder called images. The uploaded images should be saved there. I want to save the images in my database as a path like \images\user1.jpg.

My Create.cshtml, which I've generated from the controller, looks like this:

@model Application.Dal.User
@using (Html.BeginForm()) {
    @Html.LabelFor(model => model.Picture)
    @Html.EditorFor(model => model.Picture)
    <input type="submit" value="Create" class="btn btn-default" />
}

Now it looks like this: enter image description here

The user would have to write a path in the textfield, which is obviously wrong. I want the user to select an image, like this:

<input type="file" name="image" accept="image/*" id="inputImage" value="model => model.Picture)"/>

Which turns the field into (Choose file): enter image description here

Well, thats what I want but how do I bind the selected image to model => model.Picture? I tried to put "model => model.Picture" in the value attribut of the input but it doesn't work. And if it would work, how can I make sure that the picture will be saved in the image folder?

I've looked at this page: https://forums.asp.net/t/2021506.aspx?Upload+audio+file+and+save+to+Database+in+ASP+NET+MVC+using+Codefirst+EF+ but this doesn't really explain how I can bind the picture to model => model.Picture.

I want to use clientTemplate to show dropdownList that has to be populated with actual row object child. I am asking if something like this is possible, and "rowObject"´s syntax.

grid:

@(Html.Kendo().Grid<Parameter>(Model)

   .Name("basicParamsGrid")
   .Columns(columns =>
    {
       columns.Bound(c => c.Name);
       columns.Bound(c => c.Value).ClientTemplate(Html.Partial("_parameterDropDown", rowObject).ToHtmlString());

dropDownView

@model Parameter


@(Html.Kendo().DropDownList()
      .Name("valueDrop_" + Model.Name)
      .DataTextField("Value")
      .DataValueField("ConfValue")
      .OptionLabel("PleaseChoose")
      .BindTo(Model.AvailableValues)
      //.ToClientTemplate()

)