|
Thank you very much sir.
The alternative option worked for me.
Thanks a lot for your help.
|
|
|
|
|
Hi,
I created a website in Dot Net Core 1.1.
If I am deploying my site on domain directly all static files are getting loaded and my website is running fine but as I am deploying my website in sub domain, none of the static file(css, fonts, js) is getting loaded.
Really appreciate your help in advance.
|
|
|
|
|
googled first but do not find any suitable one. so looking for a details article on repository and data access code in dotnet core unit testing
where we will not use any 3rd part library like mock or effort rather use anything built-in.
anything exist such like ?
can we unit test repository and data access code with intellitrace ? share idea. thanks
|
|
|
|
|
First of all I'd ask why you don't want to use a mocking framework, it'll make your life a lot easier. However if you don't want to use one then you can use a technique called self-shunting. That is where the test class itself acts as the mocked object and you can write any code you want in your "mocked" methods.
In this brief example I have a ProductService class that uses an IProductRepository to access the products. There's only a simply Get method but it gives you the rough idea. So in my unit test I make the test class implement IProductRepository and I mock the Get method in the test class itself.
public interface IProductRepository
{
Product Get(int id);
void Add(Product product);
}
public class ProductService : IProductService
{
private IProductRepository productRepository;
public ProductService(IProductRepository productRepository)
{
this.productRepository = productRepository;
}
public Product GetProduct(int id)
{
return this.productRepository.Get(id);
}
}
Unit test
[TestClass]
public class ProductServiceTests : IProductRepository
{
private Product Product { get; set; }
[TestMethod]
public void WhenValidGetProductIsCalledProductIsReturned()
{
this.Product = new Product { ID = 1, Name = "Test product" };
ProductService ps = new ProductService(this);
Product p = ps.GetProduct(1);
Assert.AreSame(this.Product, p);
}
[TestMethod]
public void WhenInvalidGetProductIsCalledProductIsReturned()
{
this.Product = new Product { ID = 1, Name = "Test product" };
ProductService ps = new ProductService(this);
Product p = ps.GetProduct(2);
Assert.IsNull(p);
}
public void Add(Product product)
{
throw new NotImplementedException();
}
public Product Get(int id)
{
if (this.Product.ID == id)
{
return this.Product;
}
else
{
return null;
}
}
}
|
|
|
|
|
thank you so much for giving me some idea.
|
|
|
|
|
I just started to be assigned a work station that was low on memory so I accidently removed the wrong version of the .net framework. To correct the problem, I downloaded .net framework 4.0 since that is what the application uses. This web form application uses vb.net 2010 visual studio ide.
I problem is I probably downloaded the wrong version. The application probably was using a version number 4.3 I am guessing.
Thus I am trying to determine what I need to do to solve the problem.
Here is where the steps of where the problem lies:
'retarget the project to .net framework 4.0. After the project opens, you can retarget the
1. When I try to debug the application, I get the following error message:
”Retarget the project to .net framework 4.0.
Once I see the above message, I just click the OK button. I do not know where to point the application.
2. After that point I get lots of messages that look like the following:
AttendanceLetters\App_Code\mylistbox.vb(1): Build (web): Reference assemblies for target .NET Framework version not found; please ensure they are installed, or select a valid target version.
Thus to solve the problem can you tell me the following:
1. Can you tell me and/or point to a url (link) that will solve the problem tell me how and/or how to point the application to the correct target link?
2. If that is not possible, do I need to download some version of the .net framework that the application is expecting to see? If so, how can I tell what version the application is looking for?
3. If the above solutions do not work. should I uninstall the visual studio 2010 that is on this workstation and reinstall a new version so that the application can find the correct version of the .net framework?
4. If you have a different solution would you tell me what I should do to solve the problem?
|
|
|
|
|
Hello All!
Not sure if this is the correct forum to ask this, so if not, please let me know and I will have it changed.
I have created an API for my website that Godaddy hosts on a dedicated server. I have Wordpress installed and it's on a Linux server. I created the API in Visual Studio 2015 Community and ran tests on my local PC and it works as expected. Now, I need to put it online so I can test. I am planning on having it in my WPF desktop program that when the user clicks a button it will call the API and return the result. This API will check a database to see if the license code is there and if not already used. Currently, I have static code that will return a value and not connected to the database yet.
My question: Where on my website do I put files and what files go on the website? Also, how do I find out what the actual URL will be for my button click to call the API?
Thank you in advance
modified 14-Sep-17 17:24pm.
|
|
|
|
|
Greetings again.
I have this:
sp:RadioButtonList ID="rdlmhorsepType" Text='<%#Eval("horsepType").ToString()%>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;" AutoPostBack="true" OnSelectedIndexChanged="horsepType_SelectedIndexChanged">
<asp:ListItem Text="Electric" />
<asp:ListItem Text="Recoil" />
</asp:RadioButtonList><br />
When a user enters his/her account number, if there is data associated with that account number, it populates a repeater form.
This part works fine.
The issue is that if no data is associated with that account number, I get the following error:
'horsepType' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
In other words, if RadioButtonList is null, it throws that error.
I have several of those on my Repeater control.
Any ideas how to resolve this?
Thanks a lot in advance
|
|
|
|
|
When you are building a list its items have two parts - text and value, text for display and value to select.
If you are building your list from database you have to decide how values are build, you can use the text as value too in which case text must be unique. If you want to use a text-value pair, you must ensure value is not null (which means that in this case the database must have proper values) - there is no other way, so you must choose...
If you can not change the way the data is, you must filter out those have no value or create a fallback, which uses the text in case value is null..
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Let me try to explain this one more time, hopefully better.
We have a lookup table with a list of account numbers.
For a user to fill his/her account information, s/he must first select an account from the look up table.
When that account number is entered, if any records associated with that account exists, then those records populate the Repeater control form.
Users can then either modify any existing record or enter any records that does not exist already exist with that account number.
So, in my situation, if any of those values on the RadioButtonList does not exist, then it throws the error it is throwing now.
This is not a question of inserting null value in RadioButtonList because it is a required field.
It is a question of no value existing at all and user needs to be allowed to choose of the two values but the user cannot get to that point of selecting a value when the error message doesn't let them get there.
I believe this datatable below is the source of the error.
If I can figure out a way to assign it a default value other than empty string, I think it will resolve the issue.
dr = dt.NewRow();
dr["RowNumber"] = 1;
dr["horsepType"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dt.Rows.Add(dr);
}
else
{
dt = (DataTable)ViewState["CurrentTable"];
}
ViewState["CurrentTable"] = dt;
if (dt.Rows.Count > 0)
{
Repeater2.DataSource = dt;
Repeater2.DataBind();
}
}
|
|
|
|
|
The problem is that you're setting the SelectedValue to an empty string, rather than null . If it's anything other than null , then it must exist in the list.
Try converting the empty string to null :
Text='<%# string.IsNullOrEmpty(Eval("horsepType", "{0}")) ? null : Eval("horsepType") %>'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard,
Even that elegant solution did not work. It still gives same error.
I really think that the issue has to do with the fact that no value (Electric or Recoil) exists on the database for the horsepType field.
It is not just that the value is null. It does not exist at all.
As I tried to explain to the other guy, when a user enters an account number, that account number is from a lookup table.
So, when the account number is entered, the main table is queried to see if any records associated with that account number already exists.
If yes, then the form is populated with the records for the user to either modify or leave as is.
If no record exists, then the user must enter records associated with account.
So, the issue is not the value for horsepType is null, no record of it exists.
I wonder if doing a LEFT JOIN could fix the problem.
|
|
|
|
|
I am working on a .NET Core product representing a web site server. There are HTML, JS, CSHTML, etc. files in the Team Foundation Services repository not necessarily organized in folders the same way they will end up on the system actually hosting the web site.
Is anyone aware of a utility that will take the source files, make a copy to an intermediate location, and then copy from the intermediate location to update the pages and files on the system hosting the web site?
I am changing the source files and want to see the changes reflected on the web site system, which is a VM that must be reached through an intermediate drop location. I can run the utility on the development system and the target system easily enough. It is a PITA to keep track of which files were modified and to keep copying the files by hand.
Just asking ahead of time, so I don't go rewrite the wheel.
I need a 32 bit unsigned value just to hold the number of coding WTF I see in a day …
|
|
|
|
|
in my project image is uploaded and stored using file upholder. and i need to display image in image control (for eg: in facebook we are uploading profile picture when we logged out and login the profile picture will be displayed.)..i need tat kind ..pls give me suggestion
|
|
|
|
|
You can get the idea from below link on how to retrieve image data from database and display on asp.net
Read Image from SQL With ASP.NET[^]
modified 20-Sep-20 21:01pm.
|
|
|
|
|
My requirement is straight forward. I have installed certificate , in binding added thee certificate. site is working in Https(e.g. https://abc) as expected.
But the requirement is , if any user Enters http://abc then it should redirect to https://abc
I have added the URL rewriting module. Created the Rule. The web.config file code as below
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^off$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>
</rules>
</rewrite>
Help out. Its not working.
|
|
|
|
|
This is what I use - slight differences from yours - and it works:
<rewrite>
<rules>
<rule name="httpsredirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
[edit] sorry, I'm a wombat - I just copied your original rule first time! My working one here now.
|
|
|
|
|
Yes you are right, as i have checked , this is mostly generic code which suppose to work, but my luck didn't clicked. So i went with a different way. Created a new website gave same Binding configuration (i.e. http://abc). Website contains Html file containing Js code to redirect to Https://abc. So each time user hits to Http://abc it redirects it to Https://abc by the Js code... It worked for me, But not sure how much it is recommended.
|
|
|
|
|
That's not a great path to take. First, there's no guarantee that a user browser will properly support JS, and TLS is too important of a technology to leave to chance.
The problem is most likely that you did not have the URL Rewrite module installed. There's a download at URL Rewrite : The Official Microsoft IIS Site
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hello,
I am using Visual Studio 2015, ASP.NET framework : 4.6.1
I am trying to do file upload and export to excel. both things were working fine in VS2010 but same form, same codes are not working on VS2015.
We already configured the following :-
In webconfig :-
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
In Page :-
<Triggers>
<asp:PostBackTrigger ControlID="SaveBtn" />
</Triggers>
In Page Header :-
EnableEventValidation="false"
My codes are not generating any error, but even not working as expected in VS2015. If I just copy-paste the same page/code in VS2010 it will start working.
Remember : my scriptmanager is allocated in master file.
|
|
|
|
|
I don't think you're giving enough information for anyone to be able to help. There are two processes here for starters: the upload and the export. Can you not at least narrow the problem down to one or the other?
|
|
|
|
|
Thanks members for help.
I found the solutions.
I was facing issue due to some updated features of ScripManager (ajax). I required to set few properties, as it is :-
<asp:ScriptManager ID="ScriptManager1" runat="server" AjaxFrameworkMode="Explicit">
<Scripts>
<asp:ScriptReference Name="MicrosoftAjaxCore.js" />
<asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" />
<%--<asp:ScriptReference Name="MicrosoftAjaxSerialization.js" />
<asp:ScriptReference Name="MicrosoftAjaxNetwork.js" />--%>
</Scripts>
</asp:ScriptManager>
after setting
AjaxFrameworkMode="Explicit"
my problem was resolved. about file upload control and export to excel (using response object).
but if I will only set
AjaxFrameworkMode="Explicit"
that is:- it will create another problem, it blocks few other javascripts; hence I need to set
<Scripts>
<asp:ScriptReference Name="MicrosoftAjaxCore.js" />
<asp:ScriptReference Name="MicrosoftAjaxComponentModel.js" />
</Scripts>
Now my project is working fine.
thanks a lot.
|
|
|
|
|
I have a gridview where I have checkboxes on each row. You can select the checkboxes and then hit a download button. The code returns back a multipaged pdf with the files you checkboxed.
How to do you use updateprogress to show the user that I am doing a process and to keep them from hitting download more than once. I tried with a button, but I am getting
Sys.WebForms.PageRequestManagerParserErrorException:
When I try a link button, the PDF is generated and downloaded, but no ajax updateprogress is visible.
Thanks
|
|
|
|
|
i need a chat in asp.net application as we are using in facebook. how it will be create?
|
|
|
|
|