|
The message says
'viewDataDictionary does not contain a constructor that takes 0 arguments' The problem is that MSDN isn't detailed enough. It doesn't say anywhere I could find that Html.RenderPartial should be prefixed with @ sign. That was the first thing that caused me problems. Under VS 2010, it started with <%.
And my requirements have now changed a bit. ~/Counter/counter.ascx used to count the number of visitors and overwrite the value in RLSBC.txt. I have moved that function to Start.cs to make sure it is only run once per visit. (The old method used to be run more than once per visit.) The viewDataDictionary part took id (the current number of visits) in RLSBC (RLSBC.txt) and display it as 6 characters using digits (digits.gif). Digits.gif and RLSBC.txt are both in the wwwroot/Counter directory.
Is HTML.RenderPartial / viewDataDictionary still the correct way to achieve my goals?
|
|
|
|
|
xiecsuk wrote: viewDataDictionary
That doesn't match the code you posted, which was using the ViewDataDictionary class. (Note the upper-case "V" at the start, which is lower-case in your error message.)
xiecsuk wrote: Html.RenderPartial should be prefixed with @ sign. That was the first thing that caused me problems. Under VS 2010, it started with <%.
It sounds like you've switched between view engines - you were using the older ASPX view engine, and you're now using Razor.
ScottGu's Blog - Introducing “Razor” – a new view engine for ASP.NET[^]
Introduction to ASP.NET Web Programming Using the Razor Syntax (C#) | Microsoft Docs[^]
xiecsuk wrote: Is HTML.RenderPartial / viewDataDictionary still the correct way to achieve my goals?
It sounds to me like your partial view was doing too much. The code to update the counter should not be in a view, so you've done the right thing moving it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You're right; it does start with V and not v .
Thank you so much for the two web references. That is just what I was looking for; something that gave more detail than is provided by using Peek Definition or Go To Definition off the mouse button 2 menu.
I will read through them, learn and hopefully improve my website.
Now I need to understand how to format my counter using the .gif definition.
|
|
|
|
|
I create a web page with asp.net using visual.studio. And I need to acquire data from my website and save it to my computer, in a particular folder. How can I do this? Should I write this part of the program in 'Site.Master.cs' or can you tell me more exactly what I have to do, please?
NetworkAcquisitionDevice device = new NetworkAcquisitionDevice("100.0.0.1",51212,30);
FrameSearcherSecond frameSearcher = new FrameSearcherSecond();
FormatterXorByte formatterCust = new FormatterXorByte();
DataAcquisition daq = new DataAcquisition(device, frameSearcher, formatterCust);
daq.EnableDataFormatting(true);
daq.EnableFrameSearching(true);
daq.EnableDataWriting(true); // data wil be in your harddisk.
daq.StartAcquisition();
bool stop =false;
while (!stop)
{
byte[] dataFromDevice= daq.GetData();
//process data here
}
daq.StopDataAcquisition();
daq.Reset(); // it will reset all parameters.
|
|
|
|
|
I do not understand where you are stuck.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have a web application where I have a template (word) which I need to open/save and replace some values at run time. How do I do this?
|
|
|
|
|
|
If it's a new-format file (.docx ), then you'll need to use something like DocX[^] or the Open XML SDK 2.5 for Office[^].
If it's an old-format file (.doc ), then you'll struggle to find a non-commercial library to manipulate it.
NB: Don't be tempted to try Office Interop; aside from needing an Office license for your server, it's not supported in ASP.NET:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Below is my code. I can't figure out how to find specific text and replace it
Dim byteArray As Byte()
Dim myDataTable As DataTable = objDB.GetTemplates(plan.YearCode, "Templates", plan.State)
If Not myDataTable Is Nothing AndAlso myDataTable.Rows.Count > 0 Then
byteArray = DirectCast(myDataTable.Rows(0).Item("Template"), Byte())
Else
Throw New Exception("Unable to retrieve the specified template")
End If
Using mem As MemoryStream = New MemoryStream
mem.Write(byteArray, 0, CInt(byteArray.Length))
Using doc As WordprocessingDocument = WordprocessingDocument.Open(mem, True)
??? How do I find specific word and replace it
Helper.DownloadStream("Schedule" &" .docx", mem, Helper.WORD_CONTENT_TYPE)
End Using
End Using
|
|
|
|
|
|
I've given reference in project.json file , but when i am adding namespace in cs file , it is populating issue saying this file doesn't exist. but also when i am running this project by command prompt (dotnet run ) it is working fine , but using Visual Studio it is throwing errors for namespace.
|
|
|
|
|
Giving the reference does not ensure that the latest dependencies are resolved or not. To resolve the latest dependency changes, you need to run the restore command,
$ dotnet restore
Visual Studio does that all itself in the background, can you tell me which version of Visual Studio you are using? Things got changed a lot in Visual Studio 2015 and Visual Studio 2017 — Visual Studio 2017 is based on csproj, project.json and its content doesn't matter at all there.
What is .csproj file?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
here's the problem
I've got an API with the following address (HTTP post)
http:
"headers": {
"accept": "application/json",
"content-type": "application/x-www-form-urlencoded"
},
"data": {
"username": "mrkeivan",
"password": "09126101185",
"uiId": "d960a994-0972-44ba-ae2c-2c3a01e135c1"
}
I need to call this api in another website and a mobile application, to do so I enabled Asp.net APi Cores globally in web config and WebApiConfig.cs
**in WebApiConfig.cs**
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
> as well as Web.config
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="POST, PUT, DELETE, GET, OPTIONS" />
<add name="Access-Control-Allow-Headers" value="content-Type, accept, origin, X-Requested-With, Authorization, name" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
when I call this in postman, it works perfectly
however when I call it through an ajax method or a friend of mine calls it in his mobile app project it returns the following error
> XMLHttpRequest cannot load
> http://api.novin.solutions/api/member/login. Response for preflight
> has invalid HTTP status code 404 OPTIONS
> http://api.novin.solutions/api/member/login 404 (Not Found)
I have read many articles in this matter and applied all the suggestions, but nothing fixed my problem
any help would be appreciated
|
|
|
|
|
When I made a call to that api this is the response I got
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: *
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, DELETE, GET, OPTIONS
Access-Control-Allow-Headers: content-Type, accept, origin, X-Requested-With, Authorization, name
Access-Control-Allow-Credentials: true
Date: Thu, 09 Mar 2017 10:02:31 GMT
Content-Length: 135
Note that there are multiple "Access-Control-Allow-Origin" headers. The first thing I would do is look to why that is happening and get it down to one as the browser may well reject the response as invalid (if I use IE I get an error in the console explicitly stating there are duplicate headers). This is probably happening as you are configuring it in multiple places.
|
|
|
|
|
Hi, thanx for the response
removed them, now I only have it in
- web.config and
- config.EnableCors(); in WebApiConfig
|
|
|
|
|
Now there are two
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: *
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By-Plesk: PleskWin
Date: Thu, 09 Mar 2017 11:15:52 GMT
Content-Length: 135
You only need it defined once, but you are defining it in two config files
|
|
|
|
|
How do you make this call ???
|
|
|
|
|
Via ajax and I use Fiddler to examine the response
$(document).ready(function () {
$.ajax({
type: "POST",
url: "http://api.novin.solutions/api/member/login",
data: {
"username": "mrkeivan",
"password": "09126101185",
"uiId": "d960a994-0972-44ba-ae2c-2c3a01e135c1"
}
}).done(function (data) {
alert(data);
}).fail(function (jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
});
|
|
|
|
|
you are right, i found out a line I left in the global.cs
thanx man, appreciate it.
|
|
|
|
|
this is what I get
Request
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:cache-control
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:api.novin.solutions
Origin:http://localhost:1344
Pragma:no-cache
Referer:http://localhost:1344/Home/Index
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Response
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:content-Type, accept, origin, X-Requested-With, Authorization, name
Access-Control-Allow-Methods:POST, PUT, DELETE, GET, OPTIONS
Access-Control-Allow-Origin:*
Connection:close
Content-Length:1245
Content-Type:text/html
Date:Fri, 10 Mar 2017 05:26:20 GMT
Server:Microsoft-IIS/8.5
Vary:Accept-Encoding
X-Powered-By:ASP.NET
X-Powered-By-Plesk:PleskWin
|
|
|
|
|
If that's your real password that you've just posted on a public forum, I hope it doesn't provide access to any sensitive data, and that you're going to change it as soon as the problem is resolved.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
))) don't worry it's a sample !
|
|
|
|
|
hello everyone
currently i am doing a project on XSS(Cross Site Scripting) prevention, for that i want to process a small text paragraph, contain text and java code.
example-
The Conjuring 2 is a mixed bag of a movie.....That being said, if you are someone that doesn't mind jump scares, you will most likely eat this movie up!<..........some java code here...........>
i want to separate out the text code present in between "<" and ">" so that i can process it separately.
thank you for your help.
|
|
|
|
|
You could use a regex or the DOM model to find the specific tags you are interested in.
|
|
|
|
|
|